lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Aug 4, 2016 at 7:54 PM, Soni L. <fakedme@gmail.com> wrote:
> Can we get _SELF and _SUPER?
>
> local x = 1
> function f()
>   local x = 2
>   print(_SUPER.x) --> 1
> end
> print(f())
>
> pcall(function(x)
>   if x < 0 then error() end
>   if x == 0 then return end
>   print(x)
>   _SELF(x-1)
> end, 3) --> 3; 2; 1;
>
> For performance, they would be translated by the compiler. Passing _SUPER
> around would copy all upvalues into a table, but for simplicity changing
> this table wouldn't change upvalues (e.g. no current syntactic construct can
> create a metatable).
>
> _SELF and _SUPER would be indexable and callable.

Let me check that I understand you correctly.

_SELF would be callable and _SUPER would be indexable.

Can _SUPER be indexed with a value not known at compile time?

local xx = 1
do
  print(_SUPER[string.rep("x", 2)])
end

>
> (No idea what to say next. Idk, I'm just rambling I guess .-.)
>
> --
> Disclaimer: these emails may be made public at any given time, with or
> without reason. If you don't agree with this, DO NOT REPLY.



-- 


Best regards,
Boris Nagaev