lua-users home
lua-l archive

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




On 2019-01-24 12:32 p.m., Жаботинский Евгений wrote:
"Soni "They/Them" L." <fakedme@gmail.com>:
Custom literals:

local foo = u128"10000000000000000000000000000000000000"
local bar = re"[A-Za-z_][A-Za-z0-9_]*"
Hm, yes. That is useful.
Also, in these examples the function call actually looks like a literal prefix.
If such convention is followed, it really is obvious what the code does.

Fun fact:

"%02X":format(42)
-- Error
function s(v) return v end
s"%02X":format(42)
-- "2A"
So… I guess it does not make much sense to force use of parentheses for method calls only around "primitive" string literals.

-- Evgeniy Zhabotinskiy


also give this a try:

function x(x) print("xing") return x end
x(x)
("foo"):gsub(".*", print)
x
"bar":gsub(".*", print)