Code inclusion rework #58

已关闭
belliash2019-11-02 11:39:22 +01:00创建 · 1 评论
管理员

Actually, we got 2 builtin function: include() and require(). Both of them are available only inside methods body. The proposition is to:

  • make 'require' available only on the global scope in order to include source files containing classes.
  • make 'include()' available only inside methods body, to include a part of code that will be executed during method call. Such code should be a valid AerScript code that can be executed inside method body (just like using 'eval()')

Thus 'include()' would be still a builtin function, while 'require' would become a language construct. Having that, 'include()' should allow to include code several times (i.e. in loop), while require should work as 'require_once'.

Actually, we got 2 builtin function: include() and require(). Both of them are available only inside methods body. The proposition is to: * make 'require' available only on the global scope in order to include source files containing classes. * make 'include()' available only inside methods body, to include a part of code that will be executed during method call. Such code should be a valid AerScript code that can be executed inside method body (just like using 'eval()') Thus 'include()' would be still a builtin function, while 'require' would become a language construct. Having that, 'include()' should allow to include code several times (i.e. in loop), while require should work as 'require_once'.
belliash2019-11-02 11:39:22 +01:00 添加了标签
bug
enhancement
belliash2019-11-02 11:49:27 +01:00 添加了标签
idea
,删除了标签
bug
作者
管理员

Additionally, 'import()' allows to load a shared AerScript module. Actually it is implemented as a built-in function returning TRUE on success, or FALSE otherwise. This gives the control to the software developer on potential fallback or throwing an exception it module is not available, when called from constructor for example. If we decide to rewrite it as language construct it would need to throw exception without ability to catch it from global scope.

Decision? I vote for having 'include()' and 'import()' builtin methods and 'require' language construct.

Additionally, 'import()' allows to load a shared AerScript module. Actually it is implemented as a built-in function returning TRUE on success, or FALSE otherwise. This gives the control to the software developer on potential fallback or throwing an exception it module is not available, when called from constructor for example. If we decide to rewrite it as language construct it would need to throw exception without ability to catch it from global scope. Decision? I vote for having 'include()' and 'import()' builtin methods and 'require' language construct.
belliash2019-12-14 23:30:48 +01:00 关闭此工单
登录 并参与到对话中。
未选择里程碑
未指派成员
1 名参与者
通知
到期时间
到期日期无效或超出范围。请使用 'yyyy-mm-dd' 格式。

未设置到期时间。

依赖工单

没有设置依赖项。

参考:aerscript/Aer#58
没有提供说明。