lua-users home
lua-l archive

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

It will not surprise people. They will use functions as before. "pure_function" is additional feature for special cases
It could isolate possible side effects, due to miss typing or forget to define local variable or any other reasons.
Moreover it could be combined with common function to achieve different aims.
The simples way is

pure_function fn(args)
-- ...

converted into something like this

isolate_all_upvalues(args, -- somehow remove all upvalues
function fn(_ENV,args)
-- ...

пт, 5 апр. 2019 г. в 14:00, <>:
Send lua-l mailing list submissions to

To subscribe or unsubscribe via the World Wide Web, visit

or, via email, send a message with subject or body 'help' to

You can reach the person managing the list at

When replying, please edit your Subject line so it is more specific
than "Re: Contents of lua-l digest..."

Today's Topics:

   1. Re: New feature for lua (steve donovan)


Message: 1
Date: Fri, 5 Apr 2019 08:30:24 +0200
From: steve donovan <>
Subject: Re: New feature for lua
To: Lua mailing list <>
Content-Type: text/plain; charset="UTF-8"

On Fri, Apr 5, 2019 at 8:12 AM Sergey Kovalev <> wrote:
> Let inroduce new reserved word "pure_function" into lua.
> It should work similar to usual function except
> all variables used inside are implicitly local
> no access to any upvalues or global namespace _G
> So it could interact with arguments it was passed.

The 'implicitly local' bit will be a surprise to people, I think.
Global-as-default has mostly served us well.

I'm wondering if this could not be done just as a check using bytecode
- i.e. annotate a function as 'pure' in some way and look at the
bytecode to see if it has any upvalues or globals referenced.


lua-l mailing list

End of lua-l Digest, Vol 105, Issue 12