erde-lang / erde

A programming language that compiles to Lua.
https://erde-lang.github.io
MIT License
38 stars 4 forks source link

Language Feature: Optional Chaining #32

Open bsuth opened 1 year ago

bsuth commented 1 year ago

Would be nice to support optional chaining, similar to JS. However, not sure if this is realistically viable considering the following complications:

Similar to operator assignments, optional chaining should not cause duplicate indexing to occur. For example:

print(my_expensive_function()?.my_optional_field)

The above code should only cause my_expensive_function to be called once. However, this may be quite difficult to do without incurring the overhead of an IIFE.