{"id":843,"date":"2014-10-11T11:32:04","date_gmt":"2014-10-11T03:32:04","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=843"},"modified":"2014-10-17T16:46:38","modified_gmt":"2014-10-17T08:46:38","slug":"qscript%e8%af%ad%e6%b3%95%e6%9e%84%e6%83%b3%ef%bc%880-1%e7%89%88%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=843","title":{"rendered":"QScript\u8bed\u6cd5\u6784\u60f3\uff080.13\u7248\uff09"},"content":{"rendered":"<p>QScript\u505a\u4e3a\u4e00\u95e8\u89c4\u5212\u4e2d\u7684\u89e3\u91ca\u6027\u8bed\u8a00\uff0c\u6211\u5e76\u4e0d\u5e0c\u671b\u5176\u662f\u73b0\u6709\u8bed\u8a00\u7684\u76f4\u63a5\u7ffb\u7248\uff0c\u56e0\u6b64\uff0c\u91cd\u65b0\u8bbe\u8ba1\u89c4\u5212\u5176\u8bed\u6cd5\u3002\u56e0\u4e3a\u662f\u89e3\u91ca\u6027\u8bed\u8a00\uff0c\u8981\u65b9\u4fbf\u89e3\u91ca\u5668\u89e3\u6790\u8bc6\u522b\u3002<\/p>\n<p>\u6ce8\u610f\u672c\u6587\u53ea\u662f\u4e00\u4e2a\u6784\u60f3\uff0c\u5e76\u4e0d\u4ee3\u8868\u6700\u7ec8\u4e00\u5b9a\u4f1a\u5b9e\u73b0\u3002<\/p>\n<p>1\u3001\u53d8\u91cf\u5b9a\u4e49<\/p>\n<p>QScript\u4e2d\u53d8\u91cf\u5b9a\u4e49\u8bbe\u60f3\u58f0\u660e\u5f62\u5f0f\u662f\u548cC++\u7c7b\u4f3c\uff0c\u968f\u7528\u968f\u58f0\u660e\uff0c\u800c\u4e0d\u662f\u50cfDelphi\u4e00\u6837\uff0c\u9700\u8981\u5728\u524d\u9762\u58f0\u660e\u3002\u5982for\u5faa\u73af\uff1a<\/p>\n<pre class=\"lang:c++ decode:true\">for(int i=0;i&lt;100;i++)\r\n\u00a0 \u00a0{\r\n   }\r\n<\/pre>\n<p>\u53d8\u91cf\u7684\u58f0\u660e\u65f6\uff0c\u591a\u4e2a\u540c\u4e00\u7c7b\u578b\u7684\u53d8\u91cf\u58f0\u660e\u53ef\u4ee5\u7528\u9017\u53f7\u5206\u9694\uff0c\u4e0d\u540c\u7c7b\u578b\u7684\u53d8\u91cf\u5fc5\u9700\u4f7f\u7528\u5206\u53f7\u5206\u9694\u5199\u5230\u4e0b\u4e00\u53e5\u3002<\/p>\n<p>2\u3001\u51fd\u6570\u58f0\u660e<\/p>\n<p>QScript\u7684\u51fd\u6570\u58f0\u660e\u8bbe\u60f3\u662f\u53c2\u6570JavaScript\u548cDelphi\u7684\u8bed\u6cd5\uff0c\u652f\u6301\u533f\u540d\u51fd\u6570\uff0c\u58f0\u660e\u5927\u6982\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">function \u51fd\u6570\u540d\u79f0(\u53c2\u6570\u5217\u8868) \u8fd4\u56de\u503c\u7c7b\u578b \u4fee\u9970\u89c4\u5219\r\n{\r\n\u51fd\u6570\u4ee3\u7801\r\n}<\/pre>\n<p>\u8fd4\u56de\u503c\u7c7b\u578b\u53ef\u4ee5\u7528()\u5305\u62ec\u8d77\u6765\uff0c\u4ee5\u4fbf\u8fd4\u56de\u591a\u4e2a\u53c2\u6570\u503c\uff0c\u8bed\u6cd5\u5927\u6982\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:delphi decode:true  \">(\u7c7b\u578b [\u540d\u79f0][,\u7c7b\u578b2 [\u540d\u79f02]..])<\/pre>\n<p>\u4e3e\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">function fun(int x,y) (int dx,dy) stable\r\n{\r\nreturn (x,y);\r\n}\r\n...\r\na=fun(1,2);\r\n<\/pre>\n<p>\u5219\u540e\u9762\u8bbf\u95eea\u7684\u503c\u65f6\uff0c\u53ef\u4ee5\u6309\u6570\u7ec4\u7684\u89c4\u5219a[0]\u3001a[1]\u8fd9\u6837\u5b50\uff0c\u4e5f\u53ef\u4ee5\u50cf\u5bf9\u8c61\u4e00\u6837a.dx,a.dy\u8fd9\u6837\u5b50\u3002<\/p>\n<p>\u4fee\u9970\u89c4\u5219\u652f\u6301\u4e09\u79cd\uff1a<\/p>\n<p>immutable &#8211; \u5bf9\u4e8e\u76f8\u540c\u7684\u53c2\u6570\u503c\uff0c\u5176\u8fd4\u56de\u503c\u59cb\u7ec8\u662f\u56fa\u5b9a\u7684\uff0c\u800c\u4e0d\u8bba\u5176\u4e0a\u4e0b\u6587\u5185\u5bb9\u3002<\/p>\n<p>stable &#8211; \u5bf9\u4e8e\u76f8\u540c\u7684\u53c2\u6570\u503c\u548c\u4e0a\u4e0b\u6587\u5185\u5bb9\uff0c\u5176\u8fd4\u56de\u503c\u662f\u56fa\u5b9a\u7684\u3002<\/p>\n<p>mutable \u00a0&#8211; \u6613\u53d8\u7684\uff0c\u9ed8\u8ba4\u89c4\u5219\uff0c\u5373\u4f7f\u53c2\u6570\u76f8\u540c\uff0c\u6bcf\u6b21\u6267\u884c\u5176\u8fd4\u56de\u503c\u4e5f\u4e0d\u662f\u56fa\u5b9a\u7684\u3002<\/p>\n<p>QScript\u540c\u65f6\u8ba1\u5212\u652f\u6301\u533f\u540d\u51fd\u6570\uff0c\u533f\u540d\u51fd\u6570\u53ef\u4ee5\u76f4\u63a5\u8d4b\u503c\u7ed9\u4e00\u4e2a\u53d8\u91cf\u6216\u8005\u505a\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u51fd\u6570\u3002<\/p>\n<pre class=\"lang:delphi decode:true \">function a=function(int x,y){return x+y;}<\/pre>\n<p>\u8c61\u4e0a\u9762\u7684\u4ee3\u7801\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u5c06a\u5728\u540e\u9762\u505a\u4e3a\u4e00\u4e2a\u51fd\u6570\u6765\u8c03\u7528\u3002<\/p>\n<pre class=\"lang:delphi decode:true \">int b=a(1,2);<\/pre>\n<p>QScript\u7684\u51fd\u6570\u4e0d\u7ba1\u6709\u6ca1\u6709\u53c2\u6570\uff0c\u7528\u4e8e\u5305\u542b\u53c2\u6570\u5217\u8868\u7684()\u90fd\u4e0d\u80fd\u7701\u7565\uff08\u8fd9\u70b9\u548cC++\u4e00\u81f4\uff0c\u4e3b\u8981\u76ee\u7684\u662f\u65b9\u4fbf\u89e3\u91ca\u5668\u89e3\u6790\uff09\u3002<\/p>\n<p>3\u3001\u64cd\u4f5c\u7b26<\/p>\n<p>\u64cd\u4f5c\u7b26\u6211\u7684\u8bbe\u60f3\u662f\u652f\u6301\u5f15\u7528C\/C++\u4e2d\u7684\u5404\u79cd\u64cd\u4f5c\u7b26\u548c\u89c4\u5219\uff0c\u800c\u4e0d\u518d\u91cd\u65b0\u8bbe\u8ba1\u3002\u53e6\u5916\uff0c\u5f15\u5165Delphi\u7684\u90e8\u5206\u5173\u952e\u8bcd (\u6682\u65f6\u8003\u8651 and\u3001or \u3001 xor \u3001not\u3001in) \u3002<\/p>\n<p>4\u3001\u6a21\u5757\u5316<\/p>\n<p>\u590d\u6742\u7684\u811a\u672c\u80af\u5b9a\u9700\u8981\u6a21\u5757\u5316\u4ee5\u7b80\u5316\u7ef4\u62a4\u64cd\u4f5c\uff0c\u53ea\u662f\u8fd9\u91cc\u9700\u8981\u5728C++\u7684#include\u3001Delphi\u7684use\u548cJava\u7684import\u4e4b\u95f4\u9009\u62e9\u4e00\u4e2a\uff0c\u6211\u4e2a\u4eba\u503e\u5411\u4e8eDelphi\u4e2d\u7684use\u5173\u952e\u5b57\uff0c\u7b80\u77ed\u6613\u8bb0\u3002<\/p>\n<p>5\u3001\u9884\u58f0\u660e<\/p>\n<p>\u5982\u679c\u4e24\u4e2a\u51fd\u6570\u4e2d\u76f8\u4e92\u5f15\u7528\u5c31\u4f1a\u5f15\u5165\u9884\u58f0\u660e\u7684\u95ee\u9898\uff0c\u9884\u58f0\u660e\u7684\u51fd\u6570\u76f4\u63a5\u6ca1\u5728\u51fd\u6570\u58f0\u660e\u5b8c\u6210\u540e\u6ca1\u6709\u5b9e\u73b0\u90e8\u5206\u5373\u53ef\u3002\u7c7b\u578b\u4e5f\u662f\u4e00\u6837\u3002\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">function a();\r\nclass b ['{B3EE8BCD-33F8-423F-9AE8-36893E43E8D1}'];\r\nclass c;<\/pre>\n<p>6\u3001\u8c03\u8bd5\u53ca\u65e5\u5fd7<\/p>\n<p>\u76f4\u63a5\u5185\u7f6eAssert\u3001DebugBreak\u3001DebugOut\u4e09\u4e2a\u51fd\u6570\u4ee5\u53ca__DEBUG__\u5168\u5c40\u53d8\u91cf\uff0c\u8fd9\u4e09\u4e2a\u51fd\u6570\u76f4\u63a5\u5728\u8fd0\u884c\u53ea\u5728__DEBUG__\u542f\u7528\u65f6\u4f1a\u88ab\u6267\u884c\uff0c\u5982\u679c\u4e0d\u542f\u7528\uff0c\u81ea\u52a8\u5ffd\u7565\u6389\u3002DebugBreak\u652f\u6301\u6761\u4ef6\u8f93\u51fa\u3002<\/p>\n<p>7\u3001\u5f02\u5e38\u5904\u7406<\/p>\n<p>\u63d0\u4f9btry\/except\/finally\u8bed\u6cd5\u652f\u6301\uff0c\u4ee5\u4fbf\u63d0\u4f9b\u5f02\u5e38\u5904\u7406\u3002<\/p>\n<p>8\u3001\u6570\u636e\u7c7b\u578b<\/p>\n<p>8.1\u3001\u7b80\u5355\u7c7b\u578b<\/p>\n<p>\u7b80\u5355\u7c7b\u578b\u63d0\u4f9b\u6574\u6570(8\u300116\u300132\u300164\u4f4d\u6709\u7b26\u53f7\u548c\u65e0\u7b26\u53f7\uff09\u3001\u6d6e\u70b9\uff08\u5355\u7cbe\u5ea6\u3001\u53cc\u7cbe\u5ea6\u3001\u6269\u5c55\u7cbe\u5ea6\u3001\u8d27\u5e01\u548cBCD\u7f16\u7801\uff09\u3001\u5e03\u5c14\u3001\u65e5\u671f\u65f6\u95f4\uff08\u65e5\u671f\u3001\u65f6\u95f4\u3001\u65e5\u671f\u65f6\u95f4\u3001\u65f6\u95f4\u95f4\u9694\uff09\u3001\u5b57\u7b26\u4e32\uff08ANSI\u3001UTF8\u548cUnicode\u4e09\u79cd\uff09\u3001GUID\u7f16\u7801\u3001\u53d8\u4f53\u7c7b\u578b\u3001\u679a\u4e3e\u3001\u96c6\u5408\u3001\u4e8c\u8fdb\u5236\u3001\u6570\u7ec4\u3002<\/p>\n<p>8.2\u3001\u590d\u5408\u7c7b\u578b<\/p>\n<p>\u590d\u5408\u7c7b\u578b\u4e00\u822c\u8bed\u8a00\u63d0\u4f9b\u8bb0\u5f55\uff08\u7ed3\u6784\u4f53\uff09\u3001\u8054\u5408\uff08\u5171\u540c\u4f53\uff09\u3001\u63a5\u53e3\u3001\u7c7b\u3002\u5b9e\u8d28\u4e0a\uff0c\u5b83\u4eec\u5e76\u6ca1\u6709\u672c\u8d28\u7684\u533a\u522b\uff0cQScript\u5c06\u4e0d\u518d\u533a\u5206\u7684\u90a3\u4e48\u7ec6\uff0c\u53ea\u6709\u4e00\u79cd\u7c7b\u578bclass\uff0c\u7136\u540e\u53ef\u4ee5\u4e3aclass\u5b9a\u4e49\u5c5e\u6027\u3001\u51fd\u6570\u548c\u552f\u4e00\u7f16\u7801\uff08\u4f7f\u7528GUID\u7f16\u7801\uff09\uff0c\u63d0\u4f9b\u552f\u4e00\u7f16\u7801\u7684\u76ee\u7684\u662f\u4e3a\u7c7b\u578b\u63d0\u4f9b\u552f\u4e00\u5185\u90e8\u6807\u5fd7\uff0c\u4ee5\u4fbf\u8de8\u5e93\u8bbf\u95ee\u3002\u7ee7\u627f\u4e0a\u652f\u6301\u591a\u91cd\u7ee7\u627f\uff0c\u5bf9\u4e8e\u91cd\u540d\u51b2\u7a81\uff0c\u9664\u975e\u5b50\u7c7b\u91cd\u8f7d\uff0c\u5426\u5219\u8c03\u7528\u8005\u5fc5\u9700\u6307\u5b9a\u7236\u7c7b\u578b\u7684\u540d\u79f0\uff0c\u8fd9\u6837\u5b50\u5c31\u53ef\u4ee5\u907f\u514d\u591a\u91cd\u7ee7\u627f\u7684\u51b2\u7a81\u3002<\/p>\n<p>QScript\u7684\u7c7b\u578b\u5b9a\u4e49\u53ef\u4ee5\u51fa\u73b0\u5728\u4ee3\u7801\u7684\u4efb\u4f55\u4f4d\u7f6e\uff0c\u800c\u4e0d\u8c61C++\u3001Delphi\u7b49\u5fc5\u9700\u5728\u524d\u9762\u58f0\u660e\u3002\u5982\u4e0b\u9762\u7684\u7c7b\u578b\u58f0\u660e\u662f\u5408\u6cd5\u7684\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">function MyFunction1()\r\n{\r\n...\r\nclass\r\n  {\r\n  int Age;\r\n  String Name;\r\n  } Baby;\r\nBaby.Age=10;\r\nBaby.Name=\"Jone\";\r\n...\r\n}\r\n\r\nfuction MyFunction2()\r\n{\r\n...\r\n...\r\nclass TBaby\r\n  {\r\n  int Age;\r\n  String Name;\r\n  };\r\nTBaby Baby1,Baby2;\r\nBaby1.Age=10;\r\nBaby1.Name=\"Jone\";\r\nBaby2.Age=12;\r\nBaby2.Name=\"Deny\";\r\n...\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>QScript\u505a\u4e3a\u4e00\u95e8\u89c4\u5212\u4e2d\u7684\u89e3\u91ca\u6027\u8bed\u8a00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[],"class_list":["post-843","post","type-post","status-publish","format-standard","hentry","category-delphi"],"views":3627,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=843"}],"version-history":[{"count":7,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/843\/revisions"}],"predecessor-version":[{"id":942,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/843\/revisions\/942"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}