-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easy syntax for variable construction in expression context #11
Comments
Approach with make_array and make_tuple as separate operators seems to be interesting. It doesn't require type name specifying - exact type will be evaluated based on actual argument count and types. |
It may be possible to always parse postfix |
Suggestions for initialization invocation syntax:
It's better to avoid lexems like |
Now it's possible to create structs in expression context with |
Right now it is possible to construct temp variable in expression context by using type name and
()
operator (for constructor call). It works fine, but works only for cases where constructor initializer is applicable - for fundamental types, classes, for copying of arrays/tuples.It might be good to introduce some syntax for construction of temp variable with arbitrary initializer - sequence initializer (arrays, tuples), struct named initializer, zero initializer uninitialized initializer.
For structs it may my possible to allow struct named initializer as expression postfix operator. For now introducing
{}
in expression context doesn't break something.Sequence initializer "as is" is not possible to use in expression context. It starts with
[
- exactly like indexation operator.Alternative way to simplify temp variables construction for arrays and tuples is to introduce some special operators for this. Right now there are make_array and make_tuple standard library functions. They work somehow, but it may be better to implement same functionality inside language core - at least compilation may be faster.
Yet another way - to add some proxy syntax operator. Like some lexem or sequence of lexems that triggers parsing of initializer. For example (with
@)
:The text was updated successfully, but these errors were encountered: