Closed andresaraujo closed 6 years ago
There are two separate features here, argument shorthands and destructuring. Destructuring has been discussed heavily for Dart, but is, I think, out of scope for the UI-as-code" work. There isn't a lot of local variable binding that I see in UI code, so destructuring wouldn't come into play much. I do think it's a very useful feature for other kinds of code.
The argument shorthand syntax is interesting. I haven't put too much thought into this, but I have two concerns with it, a pragmatic one and a squishier one:
var child = Thing(...);
SomeWidget(child: thing);
Instead, UI code tends to build the entire thing in one big expression:
SomeWidget(child: Thing(...));
That means that I think this shorthand syntax would rarely be applicable. My goal is to focus on syntax that is useful in a large fraction of cases, and I don't think that's true here.
var someUsefulName = Thing(...);
SomeWidget(child: someUsefulName);
To:
var child = Thing(...);
SomeWidget(::child);
I'd be sad that the code is less readable. I could certainly be wrong, but that leads me to think this wouldn't be a good fit for Dart. I do really appreciate the suggestion, though! I need to take a deeper look at ReasonML.
Hi @munificent I like the ideas on this repo,
Have you considered "property shorthand" and "destructuring"? I think these will benefit a lot when writing UI in Dart code:
Argument/Property shorthand
::
Inspired by reasonml
Why?
Destructuring
Why
Feel free to close this if its not in scope for this repo.