Question about feasibility: option to use JS function syntax for nested functions, especially inside dicts/object-literals
See original GitHub issueI would like to be able to ~mix function syntaxes a bit~ try allowing JavaScript function syntax for [nested] anonymous functions. Has that been explored before? Any warnings before I explore it?
Context:
In the RapydScript code in the README, I find the nested/inlined anonymous functions difficult to read. I understand the reasoning, and I “get” the ; workaround/idiom. I would just be very curious how RapydScript looks/feels if it allows for optional curly brackets on anonymous functions. If needed, maybe those could be with function as the keyword instead of def? That would feel like a good compromise to me.
(Alternatively, the braces version of function syntax could be arrow-function style like (foo) => { return ... } … which might be good for certain libraries’ APIs.)
I can take a stab at prototyping this, to see what we think. I just figured I would ask about it before I start throwing code around 😸
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)

Top Related StackOverflow Question
For object-literal’s functions defined using indentation comma is optional, so you can:
or even:
if you still need extra begin/end tokens you can always use parentheses:
I totally agree about
;, but what’s the problem with newline+de-indentation? This is almost the same as in the class definition, no?Sorry, there should be a comma between the 2 arguments I missed:
takesTwoCallbacks(def(): return 2 + 2;, def(): return 3 ^ 2;)
On Wed, Jan 5, 2022 at 11:02 PM Alexander Tsepkov @.***> wrote: