You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{foo} for {foo: foo} is nice. As discussed in Discord, let's extend to:
{foo.bar} for {bar: foo.bar}
{foo()} for {foo: foo()} (note: avoid conflict with methods with empty bodies)
{foo.bar().baz} for {baz: foo.bar().baz}
One catch is that this (specifically foo()) forbids methods with empty bodies. I think this is a useful trade-off, but we might want to figure out a nice empty body notation (perhaps do, as in foo() do).
[DONE] JSX without braces
All of these would automatically work as JSX attributes. Furthermore, they are all unambiguous without the braces in JSX, so should be supported without them (just like ...foo is currently shorthand for {...foo}). This is especially valuable for things like props.foo (meaning foo={props.foo}) or foo() (meaning foo={foo()}), both common patterns in SolidJS. But a bare foo would remain as-is, instead of foo={foo}.
Related, we also discussed one of the following notations for common stems:
foo.{a,b,c} for {foo.a, foo.b, foo.c} i.e. {a: foo.a, b: foo.b, c: foo.c}
foo{a,b,c}
Or allow both (similar to ?.( and ?()
We can also imagine more complex chains like foo.{a,b}.{c,d}, which I imagine expanding to {foo.a.c, foo.a.d, foo.b.c, foo.c.d}. I'm less certain this is useful. But something like foo.{a,b.c} for {foo.a, foo.b.c} almost certainly would be useful.
We should also allow foo.{a,b,c} = bar (and maybe foo{a,b,c} = bar) to mean foo.a = bar.a, foo.b = bar.b, foo.c = bar.c or perhaps Object.assign(foo, bar.{a,b,c}). Actually, {a: foo.a, b: foo.b, c: foo.c} = bar works, just like the non-assingment case.
We can support spreads in this case: foo.{a,b,...rest} = bar means {a: foo.a, b: foo.b, ...foo.rest} = bar.
When the right-hand side is a literal, so we already know what the keys are, perhaps we could allow foo.{} = {a: 1, b: 2} or foo. = {a: 1, b: 2} or foo.= {a: 1, b: 2}. More generally, we could implement foo.{} = bar via Object.assign(foo, bar), bar (but should really use refs).
The text was updated successfully, but these errors were encountered:
[DONE]
{foo.bar().baz}
{foo}
for{foo: foo}
is nice. As discussed in Discord, let's extend to:{foo.bar}
for{bar: foo.bar}
{foo()}
for{foo: foo()}
(note: avoid conflict with methods with empty bodies){foo.bar().baz}
for{baz: foo.bar().baz}
One catch is that this (specifically
foo()
) forbids methods with empty bodies. I think this is a useful trade-off, but we might want to figure out a nice empty body notation (perhapsdo
, as infoo() do
).[DONE] JSX without braces
All of these would automatically work as JSX attributes. Furthermore, they are all unambiguous without the braces in JSX, so should be supported without them (just like
...foo
is currently shorthand for{...foo}
). This is especially valuable for things likeprops.foo
(meaningfoo={props.foo}
) orfoo()
(meaningfoo={foo()}
), both common patterns in SolidJS. But a barefoo
would remain as-is, instead offoo={foo}
.This is now implemented! (#508)
[DONE] Glob notation
Related, we also discussed one of the following notations for common stems:
foo.{a,b,c}
for{foo.a, foo.b, foo.c}
i.e.{a: foo.a, b: foo.b, c: foo.c}
foo{a,b,c}
?.(
and?(
)We can also imagine more complex chains like
foo.{a,b}.{c,d}
, which I imagine expanding to{foo.a.c, foo.a.d, foo.b.c, foo.c.d}
. I'm less certain this is useful. But something likefoo.{a,b.c}
for{foo.a, foo.b.c}
almost certainly would be useful.This is now implemented! (#333, #331, #327)
[PARTLY DONE] Assignment globs
We should also allow
foo.{a,b,c} = bar
(and maybefoo{a,b,c} = bar
) to meanfoo.a = bar.a, foo.b = bar.b, foo.c = bar.c
or perhapsObject.assign(foo, bar.{a,b,c})
. Actually,{a: foo.a, b: foo.b, c: foo.c} = bar
works, just like the non-assingment case.We can support spreads in this case:
foo.{a,b,...rest} = bar
means{a: foo.a, b: foo.b, ...foo.rest} = bar
.Above is now implemented! (#333, #343)
When the right-hand side is a literal, so we already know what the keys are, perhaps we could allow
foo.{} = {a: 1, b: 2}
orfoo. = {a: 1, b: 2}
orfoo.= {a: 1, b: 2}
. More generally, we could implementfoo.{} = bar
viaObject.assign(foo, bar), bar
(but should really use refs).The text was updated successfully, but these errors were encountered: