Open JaRoLoz opened 1 year ago
You can already do an object destruction but not in the parameters, example:
function someFunction(obj)
prop1, prop2 = ...obj
print(prop1, prop2)
end
However, we could also add the version you mentioned, have you seen similar syntax yet? (like a documentation of some languages or something) @MrFreex what do you think?
I've been searching for any documentation on how to implement it, but haven't found anything. What i've came up with is just replacing the destructured object in the parameters with a dummy parameter name, such as __parameter
, and then replacing the used propperties of the object inside the function with __parameter.property
. Example:
# before preprocessing
function myFunction({ prop1, prop2 })
print(prop1, prop2)
end
# after preprocessing
function myFunction(__parameter)
print(__parameter.prop1, __parameter,prop2)
end
that method could be quite a challenge since leap works on regex, it does not use AST or parser, so it is quite complicated to do it with regex.
Hi, it would be nice if this syntax could be implemented: