#25 rest variables not permitted at top level of pattern

release 0.7
closed-rejected
pyke (39)
5
2009-02-15
2009-02-11
Anonymous
No

I get a syntax error if I have the following pattern in the LHS of a FC rule:
fb.fact($b,$action,yes,$explanation,*$rest)

However, the following is permitted:
fb.fact($b,$action,yes,$explanation,(*$rest))

Shouldn't both be permitted?

-Randy

Discussion

  • Bruce Frederiksen

    • status: open --> closed-rejected
     
  • Bruce Frederiksen

    Each argument to a fact (or goal) is a separate pattern. This is the reason that *$rest is not allowed (since *$rest outside of parenthesis is not a legal pattern).

    As you've probably already figured out, you may use tuples as fact arguments to get a variable number of items. Then you can use the *$rest within a tuple pattern to match that argument. With the use of tuples, it doesn't seem necessary for a *$rest capability for fact arguments.

     

Log in to post a comment.