Skip to content
Snippets Groups Projects
Commit 72b3ce3d authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add automatic conversion of tuples to R^d as function arguments

For consistency as tuple can be used to initialize R^d elements such as in
``
R^3 x = (1,2,3);
``
they can be used as function parameters

``
let f: R^3->R, x -> x[0]+x[1]+x[2];

R x = f((1,2,3));
``
Observe mandatory parenthesis surrounding the tuple. Their prevent ambiguous
writing. For instance one can write

``
let f: R*R^3*R^2->R, (t,x,y) -> t*(x[0]+x[1]+x[2])*y[0]+y[1];

R x = f(2,(1,2,3),(2,1.3));
``
Obviously, `f(2,(1,2,3),(2,1.3))` makes complete sense, while without these
parenthesis, `f(2,1,2,3,2,1.3)` would require non-trivial decoding.
parent 48aad214
No related branches found
No related tags found
1 merge request!37Feature/language
...@@ -146,7 +146,8 @@ struct close_parent : seq< one< ')' >, ignored > {}; ...@@ -146,7 +146,8 @@ struct close_parent : seq< one< ')' >, ignored > {};
struct expression; struct expression;
struct parented_expression : if_must< open_parent, expression, close_parent >{}; struct parented_expression : if_must< open_parent, expression, close_parent >{};
struct function_argument_list : if_must< open_parent, list_must< expression, COMMA >, close_parent >{}; struct tuple_expression;
struct function_argument_list : if_must< open_parent, list_must< sor< tuple_expression, expression >, COMMA >, close_parent >{};
struct function_evaluation : seq< NAME, function_argument_list > {}; struct function_evaluation : seq< NAME, function_argument_list > {};
struct primary_expression : sor< BOOL, REAL, INTEGER, LITERAL, function_evaluation, NAME, parented_expression > {}; struct primary_expression : sor< BOOL, REAL, INTEGER, LITERAL, function_evaluation, NAME, parented_expression > {};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment