chaos-lang / chaos

The Chaos Programming Language
https://chaos-lang.org
GNU General Public License v3.0
281 stars 17 forks source link

Returning mathematical or logical expressions is not supported? #66

Open ghost opened 4 years ago

ghost commented 4 years ago

@mertyildiran @melihs Is return broken?

num def sum(num x, num y)
        return x + y
end

error:

Syntax error:                                                           
    Module: /Users/lewek/Desktop/chaos-master/__interactive__.kaos     
    Line: 1                                                               
    Cause: + 

Maybe I should make:

num def sum(num x, num y)
        num z = x + y
        return z
end
mertyildiran commented 4 years ago

@lewek I've implemented return chaining(see) in such a way that; you need to return a variable name rather than a mathematical expression or a logical expression. Because of that, your first example is not supported in the grammar. Though it's probably my fault to not implement it in a better way. Maybe you would like to reimplement that part with covering cases like this?