-
Notifications
You must be signed in to change notification settings - Fork 2
Description
The current function syntax $(arg): body is not sufficient for two reasons:
- it is confusing because
$is the sigil reserved for dereferencing (which is used in function invocation), but the definition of a function is not a dereference. - Only being able to define function properties in terms of an anonymous function is cumbersome and prone to right-ward drift.
For example, to define an <AboutCard> react component, it looks like
<AboutCard>:
$(props):
$<>:
- $<span>: Hello
- $<span>: GoodbyeThe first change, would be to use ()=> for anonymous functions:
<AboutCard>:
(props)=>:
$<>:
- $<span>: Hello
- $<span>: GoodbyeThis clearly marks that there is no de-referencing happening, but rather this is a static value.
The second is the ability to define a function property in a single place:
<AboutCard>(props):
$<>:
- $<span>: Hello
- $<span>: GoodbyeOpen Questions
We've talked about using rest options mappings to provide local bindings as a stand-in for destructuring (#15). E.g.
greet:
(person)=>: Hello %($name)
name: "%($person.first) %($person.last)"Would this be possible with "method syntax" where you have multiple function properties in the same map? At first appearance it does not seem so. You could always use $let/$do but then you have a tension of "do I want a convenient function body", or "do I want a convenient function declaration syntax?"
If we were to define this same function using method syntax:
greet(person):
$let:
name: "%($person.first) %($person.last)"
$do: Hello %($name)Is there a way to have it both ways?