Closed haasn closed 13 years ago
Looks good, but where would you define the arguments for tgis function? Or is it: no statement, no arguments? In that case, how do we separate (arguments) and (body) if they both use ()'s?
Sent via Hubroid
Nevermind that, I just saw that the draft says function{}(). I'm used to it being the other way around, I like it.
Sent via Hubroid
I have not worked lists into the spec yet but once they're in, it will be something like
>implying OP isn't >function{args} (
>mfw >len args
>mfw args[0]
)
Of course, if you can find a way to make this more /g/ related, I'm open to suggestions.
The reasoning why I swapped them, {} and (), is because the () is not just used for functions. () is used for all blocks and can be omitted if not needed.
For example, a function which only performs a single statement could look like:
>implying foo isn't >function{x} >mfw x
That being said, one potentially confusing thing could be the fact that () denotes blocks (which are statements), but statements are not expressions, so an unfamiliar user could accidentally try something like >mul 3 (>add 2 5) which is of course illegal. We could also swap them, as this would probably get rid of this ambiguity (and free up parentheses for other tasks, eg. grouping math if we're going to add infix operators)
If we swapped them, functions would look a bit more familiar:
>implying OP isn't >function(args) {
>mfw args[0]
}
I'll leave this up for debate.
Ps. I added you to the contributors list so you can push commits to this repository directly.
I've swapped them around for now, since it probably does make more sense this way.
As per the current draft, this would look something like
How does that look?