- This topic has 1 reply, 1 voice, and was last updated 11 years, 4 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘Internals & Enhancements’ is closed to new topics and replies.
Integrated Application Platform
Integrated Application Platform › Forums › Internals & Enhancements › More new features – parameters
A couple more upcoming language features.
Implicit Dynamic Parameters – you can now write:
f = function(_foo) { Print(foo) }
f(123) => 123
_foo = 123; f() => 123
This can be used with class methods as well as standalone functions. (But not with blocks.)
One of the uses for this feature is to do dependency injection.
The other feature is a shortcut. You can now write:
class
{
New(.foo, .Bar)
{
...
}
...
This is equivalent to:
class
{
New(foo, bar)
{
.foo = foo
.Bar = bar
...
}
...
The two features can also be combined:
New(._foo)
For more details, see my blog posts about these features:
I just discovered that Google’s Dart language has a similar shortcut for parameters.
class MyClass {
String str;
MyClass(this.str) {
}
Dart’s syntax is virtually identical to Suneido’s, except we can use .str as short for this.str
It’s alway interesting to see different people converge on similar designs.