You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we have a makeArray primitive that works very much like an array literal, except that it works with elements that are expressions, instead of plain data like literals do. Currently we only generate code for makeArray if indices are constant (we know which element to pick at codegen time).
Why can our normal array literals not contain arbitrary expressions?
Should we generate code for non-constant indices, and how?
Why do we need array literals when we can use array constructors like makeArray?
Personally, I would like to solve both of these questions by removing the makeArray primitive. Instead of plain data, normal array literals would take elements of expression kind.
Additonnaly, a selectArray -- or differently named high-level construct -- would also allow to create arrays as a combination of generate and select. This would generate C code with if statements or ternaries to pick the right element. If indices are constant, we should simplify the branching away.
Currently we have a
makeArrayprimitive that works very much like an array literal, except that it works with elements that are expressions, instead of plain data like literals do. Currently we only generate code formakeArrayif indices are constant (we know which element to pick at codegen time).Why can our normal array literals not contain arbitrary expressions?Personally, I would like to solve both of these questions by removing the
makeArrayprimitive. Instead of plain data, normal array literals would take elements of expression kind.Additonnaly, a
selectArray-- or differently named high-level construct -- would also allow to create arrays as a combination ofgenerateandselect. This would generate C code with if statements or ternaries to pick the right element. If indices are constant, we should simplify the branching away.@rise-lang/core