VarTuple may not be needed
The variable tuple causes several complications in the grammar and the interpreter.
- Grammar. The
=
and the parameter in theVariable
rule
Variable:
name = TrueID &/,|\)|=/ ('=' parameter = Parameter)? (resources = Resources)?
;
are optional only because Variable
is used in the VarTuple
rule:
VarTuple:
'(' variables += Variable[','] ')' '=' parameter = VarTupleParameter
;
This is why tab-completer shows no hint for =
after an identifier is entered. It shows (
at beginning of a line instead and only :=
after an identifier.
-
Special treatment in processors:
- in
src/virtmat/language/metamodel/deferred.py
:deferred_vartuple_processor
- in
src/virtmat/language/metamodel/workflow.py
:source_code_statement_processor
- in
-
In interpreters in
variable_value
,variable_func
In order to remove the rule, first we have to implement subscripting tuple parameters, for example this a = (1, 2); print(a[0])
should work. Then in the usual use case of the rule, such as (a, b) = f(c)
this code can be used: aux = f(c); a = aux[0]; b = aux[1]
. It has more lines but the parse and interpreter will work more efficient and robust and there is no need of the processors and special cases. In addition, the evaluation of vartuple is hard to parallelize, whereas the alternative realization is parallelized with no further effort.