Re: extensions for luajit

  • From: Laurent Deniau <Laurent.Deniau@xxxxxxx>
  • To: "<luajit@xxxxxxxxxxxxx>" <luajit@xxxxxxxxxxxxx>
  • Date: Wed, 21 Aug 2013 10:08:51 +0000

On Aug 21, 2013, at 10:56 AM, steve donovan wrote:

> On Wed, Aug 21, 2013 at 10:11 AM, Laurent Deniau <Laurent.Deniau@xxxxxxx> 
> wrote:
>> It makes long and difficult to read complex mathematical formula when the 
>> variable are not parametric.
> 
> OK, now I understand. That does seem like a good use case.  Making it
> efficient would be the hard part, after defining the semantics
> clearly.
> 
> You can use LuaMacro to implement something like this, since a macro
> can generate macros; these macros can 'shadow' an existing variable
> and do something at each occurence
> 
> parm x,y  -- generates macros x,y that shadow variables x,y
> ...
> print(x, y)
> 
> =>
> 
> local x,y
> ....
> print(x(), y())
> 
> But I understand you would like x to either evaluate as x (if it is
> already a final value) or as x() (if it is a closure). That is tricky,
> and probably hard to optimize.  LM could wrap all such parameters as
> 'eval(x)' but that function becomes the bottleneck.

The approach of using LuaMacro is the actually retained but as you mention, we 
may have to face some complexity/inefficiency. Hence, I was asking if it was 
not possible to patch LuaJit and add some tag or flag to internal function 
definition to tell it that our lambda (i.e. function with no arg defined with 
the lambda syntax) could be evaluated instead of returning the address when the 
parenthesis are missing. That would be a zero runtime cost as everything would 
be done during parsing when the AST is evaluated (before optimization?) and 
very useful in many applications.

Best,
Laurent.



Other related posts: