xray-tech / xorc-oam-compiler

xorc.io implementation of the Orc programming language
Apache License 2.0
2 stars 0 forks source link

guard not implemented for lambda #10

Open jsulmont opened 6 years ago

jsulmont commented 6 years ago

the following code:

def czad(a) = lambda(b) if (a+b = 0) = a+b 

czad(2)(-2) | czad(3)(4) | czad(0)(0)

fails to compile:

[ERROR] Can't compile:
 0: def czad(a) = lambda(b) if (a+b = 0) = a+b #
                              ^--- Syntax error at line 0 column 26: LAMBDA LEFT_PAREN RIGHT_PAREN WILDCARD
 (error code 178)
 1:
 2: czad(2)(-2) | czad(3)(4) | czad(0)(0)
 3:
prepor commented 6 years ago

this is not a bug, even official orc doesn't have guards for lambda in their syntax definition (https://orc.csres.utexas.edu/documentation/html/refmanual/ref.syntax.EBNF.html)

what's the case of a guard for lambda? it can't have multiple clauses anyway, why not just put if into lambda's body itself

jsulmont commented 6 years ago

the EBNF syntax is quite outdated -- Orc-2.1.2 compiles/executes this code.