New getter and setter syntaxWe heard lots of feedback from users that they don't like the new setter syntax. Instead, we'll keep the current syntax, so no more "=" after the setter name. Instead, just:set blah(value) => ...We will go ahead with the getter changes (removing ()).Ryan Dahl's thread on miscGo's syntax for loops and stuff versus Dart's is really just a matter of taste. Dart tries harder to be similar to other languages to make it easier for users to get comfortable and to make porting code easier.We talked a bit about optional semicolons. There is some vague worry that we could end up with some of the problems that JavaScript has. For now, we don't have any plans to make them optional. But, since doing so wouldn't be a breaking change, we can always decide to do that later.Lots of people don't like "&" for export. Message received: we'll do something different. Not sure what yet.Parameter listsWe have a design for a modification to parameter lists that lets you define optional positional parameters that are not also named. Sometime soon, I'll see if I can get a document out that explains it.We won't know how well this works until we port code to use it. We aren't sure how many of the current APIs are using optional parameters positionally or by name. So we'll try it out and see if we need to iterate on it again.CascadesAre implemented everywhere now (VM, dart2js, editor). Users can start playing with them!
Non-const staticsThese are coming soon. This means you'll be able to initialize top-level final variables, and static final fields using non-const initializers. They will be lazily evaluated the first time the variable is accessed.
Thanks for the update Bob!What was the consensus on doing the C# blocked getter/setter? I still think that's the best way to do it as it simplifies the setters greatly.
Thanks for bringing it up Bob. Its not the end of the world if they keep the getter/setter stuff as is, but I personally think the semantics are helpful when programming. Its one of the things I really liked when I did some C# work, and wished was around when programming in C++, so apologies if I'm harping on this a bunch.
It also bugs me that with how they're declared currently resembles how a method is declared. By not having () or (Foo value) within the getter/setter to me there is an implication that this is not a method but something different. Yes it might just be syntatic sugar around a getFoo/setFoo combo under the hood, but I feel as though having a property syntax that is different reinforces that they are something semantically different than a method.
--
Hey Bob,I've probably mangled my terms here. The implied meaning of the syntax of properties chosen in Dart is what I was taking issue with. Semantics was probably not the best word to use there, since this is still a syntax issue, but let me explain what I meant.
So with the C# style declaration its blocked thus showing there's an association between the getter and setter. As I've mentioned having value passed implicitly to the setter, and having a definitive place to comment are big wins from this declaration style. There's also the weirdness for those who are typing everything that the get has a return type but the set does not, so the pairing of the two looks odd.
It also bugs me that with how they're declared currently resembles how a method is declared.
By not having () or (Foo value) within the getter/setter to me there is an implication that this is not a method but something different. Yes it might just be syntatic sugar around a getFoo/setFoo combo under the hood, but I feel as though having a property syntax that is different reinforces that they are something semantically different than a method.
This is actually a feature from the perspective of the language designers, I think. In Dart, getters and setters are just methods, and there's no actual relationship between a getter and setter that happen to have the same name. They're just two different unrelated methods.
That's the balance they are trying to strike. Under the hood, methods aren't different from methods. But the syntax for using them is. So the declaration syntax has to try to span those two facts. It's tricky.
This is actually a feature from the perspective of the language designers, I think. In Dart, getters and setters are just methods, and there's no actual relationship between a getter and setter that happen to have the same name. They're just two different unrelated methods.It's the word "just" that I have trouble with. Can we at least agree that we'd never let a coworker write a getter and setter that actually were unrelated to each other?
That's the balance they are trying to strike. Under the hood, methods aren't different from methods. But the syntax for using them is. So the declaration syntax has to try to span those two facts. It's tricky.What they are under the hood is an irrelevant implementation detail. I'd imagine that's what they are under the hood in any language.
But there is more to the meaning of language constructs than what they mean to the compiler; language features are important for what they help us communicate to other programmers and as tools for thinking about the problems we're solving. And properties have a different meaning from methods. If you are writing code that is best thought of as a method, you should implement it as a method. A property is best thought of as something like a field, but more flexible, and the syntax for using getters/setters reflects that; it isn't "balance" to make the syntax for defining them suggest something else.
Granted, a look around the Dart API suggests that the Dart team hasn't yet reached a consensus on what the difference is between properties and methods, but I'd imagine a lot of the API designers aren't used to programming in languages with properties.
I don't mind the syntax so much as the mindset behind it -- after all, if properties are "just two different unrelated methods,"
No, in C#, properties are distinct from both fields and methods. This is visible in the reflection system and affects stuff that uses reflection. For example, if you ever used the PropertyGrid class in C#, it only showed the properties of your class, not its fields.
Granted, a look around the Dart API suggests that the Dart team hasn't yet reached a consensus on what the difference is between properties and methods, but I'd imagine a lot of the API designers aren't used to programming in languages with properties.This is true, although I believe consensus is emerging. The main problem is that much of the corelib is long overdue for an overhaul. Things like the collection types haven't been touched for almost a year.
Good to hear the issue hasn't dropped off the radar. I'd suggest the golden rule for properties versus methods should be, "Is it obvious from the name you've chosen that this is a method, not a property? If not, it's a property. If in spite of this you still think it should be a method, change the name."