[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: "Ignore me" symbol
- From: Sam Pagenkopf <ssaammp@...>
- Date: Tue, 18 Dec 2018 01:03:55 -0600
Apologies for rehashing, must have skimmed the thread too hard. I suppose the overhead would kick in with functions that often use large inline literals. If you can keep them all in the outermost local scope, it's annoying but the performance impact virtually disappears.
I just did some testing, surprised that even luaJIT doesn't realize such literals are constant at compile-time.
On Tue, Dec 18, 2018 at 12:34 AM Sam Pagenkopf <email@example.com> wrote:
> I think inline backtick comments are unneeded, --[[inline comment]] is good enough.
> Never saw a problem with _G.THING for explicit globals, someone let me know if I'm wrong.
> For long literals, there's a workaround:
> function num (n, base) return tonumber(n:gsub('_', ''), base or 10) end
> assert(num '100_000' == 100000)
> And don't forget the 4e10 syntax for literals with lots of zeroes.
> assert(1e5 == 100000)
> And if you really hate names like setmetatable and collectgarbage, just rename them locally.
The workaround has already been explicitly shot down in this thread:
it's a runtime transformation which means you take a performance hit
every time you use one. It HAS to be done at the lexer level to be
practical for anything that needs to worry about scalability. This
plus binary literals are things that have been in demand for quite a
while and they're things I think are worth doing -- though they're
things that can be done with token filters, too.
Inline long comments with --[[ ]] work fine for comments. The proposal
was actually trying to ask for an annotation syntax and just did a
poor job getting the point across. That's why other posters have
talked about syntaxes like @annotation(param, param) as something that
could be parsed cleanly but be a no-op in the interpreter so that
other tools can use the markup to do other tasks. Inline comments do
WORK for this, but they're a little bit on the verbose side and people
would like something with a bit better integration. That said, while I
understand the desire and intent, I don't particularly have a strong
opinion about it myself.