From 72b3ce3d7fb051f670e046ae448aa033a271d3a1 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Wed, 12 Feb 2020 17:08:02 +0100
Subject: [PATCH] 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.
---
 src/language/PEGGrammar.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/language/PEGGrammar.hpp b/src/language/PEGGrammar.hpp
index 2a8ea0374..00e21818e 100644
--- a/src/language/PEGGrammar.hpp
+++ b/src/language/PEGGrammar.hpp
@@ -146,7 +146,8 @@ struct close_parent : seq< one< ')' >, ignored > {};
 struct expression;
 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 primary_expression : sor< BOOL, REAL, INTEGER, LITERAL, function_evaluation, NAME, parented_expression > {};
-- 
GitLab