3

I found in some demo code, both *x and x* are used. Sometimes, the star is also used on types, like *int xs. In the help, only the pattern Var* is documented. Is there any difference between putting the star before or after a pattern variable?

day
  • 2,292
  • 1
  • 20
  • 23

1 Answers1

2

Good question. The answer is both yes and no:

  • Yes: The post-fix * is deprecated, since it triggers syntactical ambiguity with post-fix transitive closure in some weird contexts on the expression side of things. This does not happen in patterns, but for consistency we want to have the prefix * mean "splat" in patterns and "splice" in expressions, as dual operators, and remove the post-fix * to avoid confusion.
  • No: when applied to a variable in a pattern they will have the same semantics.

So, please use the prefix + and prefix * when possible to avoid upgrade pain in the future when we remove postfix * and + from the language.

Jurgen Vinju
  • 6,393
  • 1
  • 15
  • 26
  • Thanks for the answer. But I guess you want to swap "No" and "Yes", don't you. To be sure I understand it correctly, for _cluster_ in pattern and _splice_ in expression, prefix `+` and `*` should be used, because the postfix syntax will be reserved _only_ for closure operations on relations. – day Oct 15 '13 at 13:03