PlutoLang / Pluto

A superset of Lua 5.4 with a focus on general-purpose programming.
https://pluto-lang.org
MIT License
360 stars 22 forks source link

Constexpr evaluation of user-defined functions #273

Closed Sainan closed 1 year ago

Sainan commented 1 year ago

For example:

local function add(a, b)
    return a + b
end
print($add(1, 2))

Should compile as if

print(3)

was written.

Although, for this to work we should maybe first figure out how to get this to work:

print($(1 + 2))

However, the main reason I suggest this is because I'd want something similar to the power of macros in Pluto for meta-programming.

Sainan commented 1 year ago

I think this is a bit too broad, I'll try to narrow down the exact use cases and track that in new issues.