Replies: 7 comments 3 replies
-
The other variants without parentheses would require a line break or a semicolon at the end to terminate... and I think
looks sorta ugly with the ending semicolon... |
Beta Was this translation helpful? Give feedback.
-
Fair enough... just confirming: you would accept the need to have an ending semicolon? It would not be easy to parse, as it would require checking whether an identifier is a valid function. For example, take the following code: foo; // should this be the variable 'foo'? Or 'foo()'?
foo bar, baz;
foo - bar // should this be foo - bar? Or foo(-bar)? When the parser sees So, at parsing time, it is not immediately certain whether the keyword is a variable or a function. It is also not easy to judge based on the following token... firstly there may not be one (for a function call with no arguments), second it may be a valid dual unary/binary operator (such as |
Beta Was this translation helpful? Give feedback.
-
Yeah, I would accept the need to have an ending semicolon. How its done in |
Beta Was this translation helpful? Give feedback.
-
Also it would be awesome to be able to declare functions without parenthesis (if no arguments):
|
Beta Was this translation helpful? Give feedback.
-
Actually this may be easy to add as the syntax in unambiguous... |
Beta Was this translation helpful? Give feedback.
-
Nevertheless, if we can define functions without parentheses, would people expect to be able to call them without parentheses? fn foo { ... }
let x = foo; // instead of foo() |
Beta Was this translation helpful? Give feedback.
-
I think they would, but this is not possible to call like this, parser will say that. Its also implemented in nim, and it was there for all this years, and it wasnt the problem.
This functions are expected from every script in the game and called from game engine itself. So what do you think about making semicolon optional? It looks like its easy to implement. I also could try to implement Uniform Function Call Syntax for Rhai. I could make it as an optional feature. But the question is, would you merge Uniform Function Call Syntax into the main branch? I really like this project tbh, and i want to contribute to it. So, implementing Uniform Function Call Syntax would be nice place to start. |
Beta Was this translation helpful? Give feedback.
-
I really like that
rhai
has simplified rust syntax. And its clean. But, i think it would be much more interesting and clean to implementUniform Function Call Syntax
, i saw this feature innim
andcrystal
, and its awesome! Why not to implement it inrhai
?Beta Was this translation helpful? Give feedback.
All reactions