{"id":343584,"date":"2021-02-03T12:32:30","date_gmt":"2021-02-03T04:32:30","guid":{"rendered":"http:\/\/4563.org\/?p=343584"},"modified":"2021-02-03T12:32:30","modified_gmt":"2021-02-03T04:32:30","slug":"%e6%8e%a8%e8%8d%90%e4%b8%80%e9%97%a8-lua-%e6%96%b9%e8%a8%80-teal","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=343584","title":{"rendered":"\u63a8\u8350\u4e00\u95e8 Lua \u65b9\u8a00 Teal"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u63a8\u8350\u4e00\u95e8 Lua \u65b9\u8a00 Teal               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : virusdefender <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5728\u4e00\u4e9b\u9886\u57df\uff0cLua \u4f7f\u7528\u975e\u5e38\u7684\u5e7f\u6cdb\uff0c\u6bd4\u5982\u6e38\u620f\u3001OpenResty server \u3001\u7ed9\u5176\u4ed6\u8bed\u8a00\u5d4c\u5165\u52a8\u6001\u80fd\u529b\u7684\u573a\u666f\u7b49\u7b49\u3002<\/p>\n<h2>Lua \u6709\u4ec0\u4e48\u95ee\u9898<\/h2>\n<p>\u4f46\u662f Lua \u662f\u4e00\u95e8\u975e\u5e38\u7075\u6d3b\u7684\u8bed\u8a00\uff0c\u548c\u5e38\u89c1\u7684 Python \u548c JavaScript \u7b49\u6bd4\u8fd8\u8981\u7075\u6d3b\u548c\u7b80\u5355\uff0c\u8fd9\u5c31\u9020\u6210\u4f7f\u7528\u6210\u672c\u504f\u9ad8\u7684\u95ee\u9898\uff0c\u6bd4\u5982<\/p>\n<ul>\n<li>\u4e0d\u533a\u5206 struct \u3001map \u3001\u6570\u7ec4\u7b49\u6570\u636e\u7ed3\u6784\uff0c\u4e00\u5f8b\u90fd\u662f table\uff0c\u4f7f\u7528\u8005\u5f88\u96be\u770b\u51fa\u6765\u8fd9\u4e2a\u6570\u636e\u5230\u5e95\u662f\u4ec0\u4e48\u5185\u5bb9<\/li>\n<li>\u51fd\u6570\u53c2\u6570\u548c\u8fd4\u56de\u503c\u4f20\u9012\u591a\u4e86\u548c\u5c11\u4e86\u90fd\u4f1a\u9ed8\u9ed8\u7684\u53d8\u6210 nil \u800c\u4e0d\u4f1a\u62a5\u9519<\/li>\n<\/ul>\n<p>\u6211\u4eec\u5728\u7ed9 Golang \u52a0\u5165\u52a8\u6001\u80fd\u529b\u7684\u65f6\u5019\u5c31\u9047\u5230\u4e86\u8fd9\u4e9b\u95ee\u9898\uff0c\u4ee3\u7801\u591a\u4e86\u5199\u8d77\u6765\u5f88\u75db\u82e6\uff0c\u7ecf\u8fc7\u4e00\u4e9b\u641c\u7d22\uff0c\u6211\u4eec\u53d1\u73b0\u4e86 Teal\uff0c\u4f7f\u7528\u4e86\u5927\u534a\u5e74\u4e86\uff0c\u7ed9\u5927\u5bb6\u63a8\u8350\u4e0b\u3002<\/p>\n<h2>Teal \u4ecb\u7ecd<\/h2>\n<p>Teal \u548c Lua \u7684\u5173\u7cfb\u5c31\u7c7b\u4f3c TypeScript \u548c JavaScript \u7684\u5173\u7cfb\uff0c\u652f\u6301\u7ed9\u5df2\u6709\u7684\u5e93\u8fdb\u884c\u7c7b\u578b\u6807\u8bb0\uff0c\u6700\u7ec8\u662f\u7ffb\u8bd1\u4e3a Lua \u53bb\u5b9e\u9645\u4f7f\u7528\u7684\u3002<\/p>\n<p>\u7c7b\u578b\u6807\u8bb0\u53ef\u4ee5\u5199\u5728 <code>xx.d.tl<\/code> \u6587\u4ef6\u4e2d\uff0c\u6bd4\u5982<\/p>\n<pre><code>local record os     exit: function(number) end  return os <\/code><\/pre>\n<p>\u5728 Teal \u4e2d\u4e3b\u8981\u65b0\u589e\u4e86 <code>record<\/code>\u3001<code>array<\/code> \u548c <code>map<\/code> \u7c7b\u578b\uff0c\u66f4\u591a\u7684\u8bed\u8a00\u7279\u6027\u53ef\u4ee5\u89c1\u6587\u6863 https:\/\/github.com\/teal-language\/tl\/blob\/master\/docs\/tutorial.md<\/p>\n<p>\u4ee3\u7801\u6837\u4f8b<\/p>\n<pre><code>-- record \u7c7b\u4f3c\u5176\u4ed6\u8bed\u8a00\u4e2d\u7684\u7ed3\u6784\u4f53 local record arg_t     a: string     b: string end  -- key \u4e3a\u5b57\u7b26\u4e32\uff0c\u503c\u4e3a\u6570\u5b57\u6570\u7ec4\u7684\u5b57\u5178 local m: {string: {number}} m[\"x\"] = {1, 2, 3}  -- \u5e26\u7c7b\u578b\u5b9a\u4e49\u7684\u51fd\u6570 local function add(a: number, b: number): number     return a + b end <\/code><\/pre>\n<h2>vscode \u63d2\u4ef6<\/h2>\n<p>Teal \u6709\u5e38\u89c1\u7684\u7f16\u8f91\u5668\u63d2\u4ef6\uff0c\u6bd4\u5982\u6211\u4e00\u822c\u662f\u4f7f\u7528 vscode \u8fdb\u884c\u5f00\u53d1\uff0c\u5b83\u7684 vscode \u63d2\u4ef6\u6700\u8fd1\u7ecf\u8fc7\u793e\u533a\u5927\u4f6c\u7684\u52aa\u529b\uff0c\u652f\u6301\u4e86\u7b80\u5355\u7684\u81ea\u52a8\u8865\u5168\u548c\u7c7b\u578b\u63d0\u793a\u529f\u80fd\uff0c\u540e\u7eed\u4f1a\u9010\u6e10\u7684\u52a0\u5f3a\u3002\u8be6\u89c1 https:\/\/github.com\/teal-language\/vscode-teal<\/p>\n<h2>\u4e3a\u5565\u9009\u62e9 Teal<\/h2>\n<p>\u5176\u5b9e\u5e02\u9762\u4e0a\u8fd8\u6709\u4e00\u4e9b Lua \u7684\u65b9\u8a00\uff0c\u4e3a\u5565\u9009\u62e9 Teal \u5462\uff0c\u539f\u56e0\u5982\u4e0b<\/p>\n<ul>\n<li>\u4e3b\u8981\u4f5c\u8005 https:\/\/github.com\/hishamhm \u4e5f\u662f htop \u3001luarocks \u7b49\u7684\u4f5c\u8005\uff0c\u5b9e\u529b\u5f88\u5f3a<\/li>\n<li>\u6700\u8fd1\u534a\u5e74\u793e\u533a\u53d1\u5c55\u8fc5\u901f\uff0c\u6df1\u5ea6\u7528\u6237\u6709\u4e0d\u5c11\uff0cissue \u3001feature \u7b49\u5904\u7406\u7684\u975e\u5e38\u5feb<\/li>\n<li>\u5176\u4ed6\u7c7b\u4f3c\u7684\u9879\u76ee\u5728\u8fd9\u91cc\u4e5f\u6709\u5206\u6790 https:\/\/github.com\/teal-language\/tl\/blob\/master\/docs\/other_projects.md \u8981\u4e0d\u4e0d\u7ef4\u62a4\u4e86\uff0c\u8981\u4e0d\u5c31\u7c7b\u4f3c Lua \u4e0d\u662f\u771f\u6b63\u7684 Lua<\/li>\n<li>https:\/\/github.com\/TypeScriptToLua\/TypeScriptToLua \u662f\u4e00\u4e2a\u5c06 TypeScript \u7ffb\u8bd1\u4e3a Lua \u7684\u9879\u76ee\uff0c\u6211\u6ca1\u6709\u6df1\u5165\u4f7f\u7528\u8fc7\uff0c\u8fd9\u4e2a\u65b9\u5411\u53ef\u4ee5\u5f88\u597d\u7684\u5229\u7528 ts \u7684\u751f\u6001\uff0c\u80fd\u7701\u5f88\u591a\u4e8b\u60c5\uff0c\u4f46\u662f\u6211\u4e2a\u4eba\u8ba4\u4e3a ts \u548c Lua \u8bed\u6cd5\u5dee\u5f02\u6bd4\u8f83\u5927\uff0c\u6211\u66f4\u52a0\u503e\u5411\u662f Lua with type \u800c\u4e0d\u662f\u53d8\u6210\u4e00\u95e8\u65b0\u7684\u8bed\u8a00<\/li>\n<\/ul>\n<h2>Teal \u8fd8\u5b58\u5728\u4ec0\u4e48\u95ee\u9898<\/h2>\n<p>\u56e0\u4e3a\u6211\u4eec\u4f7f\u7528\u7684\u6bd4\u8f83\u65e9\uff0c\u524d\u671f\u5b58\u5728\u4e00\u4e9b\u68c0\u67e5\u4e0d\u5b8c\u5584\u548c bug\uff0c\u6211\u4eec\u5c31\u5185\u90e8 fork \u7ef4\u62a4\u4e86\u4e00\u4e9b patch\uff0c\u5e0c\u671b\u662f\u8ba9 Teal \u4ee3\u7801\u5199\u8d77\u6765\u66f4\u50cf\u662f Golang \u3002<\/p>\n<p>\u968f\u7740\u793e\u533a\u7684\u53d1\u5c55\uff0c\u6709\u4e9b\u66f4\u52a0\u4e25\u683c\u7684\u68c0\u67e5\u5728\u5b98\u65b9\u7248\u672c\u4e2d\u4e5f\u9010\u6e10\u652f\u6301\u4e86\uff0c\u6211\u4eec\u7684 patch \u4e5f\u8d8a\u6765\u8d8a\u5c11\u3002\u6bd4\u5982\u6700\u8fd1\u4f5c\u8005\u63d0\u4e86\u4e2a\u65b0\u60f3\u6cd5\uff0c\u652f\u6301 <code>arg?<\/code> \u7684\u5f62\u5f0f\u4f20\u9012\u53ef\u9009\u53c2\u6570 https:\/\/github.com\/teal-language\/tl\/pull\/366\uff0c\u5982\u679c\u8fd9\u4e2a merge \u4e86\uff0c\u90a3\u6211\u4eec\u7684 patch \u5c31\u53ef\u4ee5\u518d\u53bb\u6389\u4e00\u90e8\u5206\u4e86\u3002<\/p>\n<p>\u8bed\u8a00\u7684\u57fa\u7840\u8bbe\u65bd\u6bd4\u8f83\u521d\u671f\uff0c\u6bd4\u5982 vscode \u63d2\u4ef6\uff0c\u80af\u5b9a\u4e0d\u80fd\u548c\u5176\u4ed6\u8bed\u8a00\u7684 IDE \u652f\u6301\u76f8\u6bd4\uff0c\u4f46\u662f\u4e5f\u591f\u7528\u4e86\uff08\u6bd5\u7adf\u6211\u4eec\u53bb\u5e74\u5199 Teal \u90fd\u6ca1\u8865\u5168\u548c\u63d0\u793a\u7684\uff09\uff0c\u6bd4\u5982\u683c\u5f0f\u5316\u5de5\u5177\uff0c\u6bd4\u5982\u6587\u6863\u751f\u6210\u5de5\u5177\u7b49\u7b49\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5293404\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : oott123 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709\u8003\u8651\u8fc7 Haxe \u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5293405\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kran <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u8d77\u6765\u975e\u5e38\u4e0d\u9519                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5293406\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gmywq0392 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u63a8\u8350\u4e00\u95e8 Lua \u65b9\u8a00 Teal &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/343584"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343584"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/343584\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343584"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}