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>: Goodbye
The first change, would be to use ()=> for anonymous functions:
<AboutCard>:
(props)=>:
$<>:
- $<span>: Hello
- $<span>: Goodbye
This 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>: Goodbye
Open 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?
The current function syntax
$(arg): bodyis not sufficient for two reasons:$is the sigil reserved for dereferencing (which is used in function invocation), but the definition of a function is not a dereference.For example, to define an
<AboutCard>react component, it looks likeThe first change, would be to use
()=>for anonymous functions:This 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:
Open Questions
We've talked about using
restoptions mappings to provide local bindings as a stand-in for destructuring (#15). E.g.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/$dobut 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:
Is there a way to have it both ways?