?“Foo”#(_) is a rather verbose and inefficient way of matching Foo with any number of arguments. Two things could be improved:

a) support a more intuitive syntax, for example ?Foo(…) (which is the syntax of parse-unit)
b) make specific forms of ?p#(p) more efficient (i.e. not explode to a tuple). in particular, matching a constant constructor with a variable number of arguments can be implemented much more efficiently.

Submitted on 24 November 2006 at 14:19

On 2 December 2006 at 22:55 Jira commented:

STR-667, martin:
Tom supports this as Foo[]. In Stratego, I would prefer the Foo(…) syntax.


On 5 December 2006 at 18:58 Jira commented:

STR-667, pierron:
and why not handle those in the same way ?

?Foo(…) -> “Foo”#(id)
?Foo(x, …) -> “Foo”#([?x | id])
?Foo(…, x, …) -> “Foo”#(at-suffix([?x | id]))
?Foo(…, x) -> “Foo”#(at-last([?x]))
?Foo(a, …, b, …, c, …, d) -> “Foo”#([?a | at-suffix([?b | at-suffix([?c | at-last([?d]) ]) ]) ])


On 7 December 2006 at 17:19 Jira commented:

STR-667, martin:
Hm, list matching, interesting :)

Indeed, it would be good if ?Foo(…) is just sugar for the # operator, where the implementation of the # operator should be optimized.

The list matching would be great to have, though we should probably consider to do this completely right (as opposed to supporting some specific forms, e.g. should list matching be greedy? What if a match fails because it was too greedy? How to deal with multiple possible matches?)


On 17 April 2008 at 10:21 Jira commented:

STR-667, pierron:
This problem should be solved to remove an asymmetric behavior of star-variables:

a := 1
; b* := [2, 3]
; c := 4
; ![a, b*, c]
; ?[1, 2, 3, 4]
; ?[a, b*, c] // fail


On 9 January 2013 at 16:58 Eelco Visser removed tag 0.18M5

On 9 January 2013 at 16:58 Eelco Visser tagged 0.19M1

On 9 January 2013 at 17:03 Eelco Visser removed tag 0.19M1

On 9 January 2013 at 17:03 Eelco Visser tagged interesting

Log in to post comments