--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
--
You received this message because you are subscribed to the Google Groups "Dart Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to core-dev+u...@dartlang.org.
var name : String; final pi : int = 3; // Close enough. hasTwo(elements : List) : bool => list.length == 2;
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
I HATE HATE HATE this. It was actually a huge ick when looking at TypeScript.var name : String; final pi : int = 3; // Close enough. hasTwo(elements : List) : bool => list.length == 2;
The only time I've used part is when I want internal privacy. What if that was implied by the library path? Like if you had .src.foo and src.bar then those two have internal privacy?
> The portion of the Dart team that comes from a Smalltalk background has long missed non-local returns. The stated reason for > not having them is that no one knows how to efficiently compile them to a language like JS which lacks them. *If our focus is> moving off the web towards execution environments we control,* Gilad would like to put them back on the table.What do you guys mean with "dart moving off the web" ? Would this non local returns also available when you compile to javascript ?
Static checking for dropped futures
Type tests
Type annotations on the right
Constructor initialization lists
Parts
Symbols
Fields final by default
non-local returns
Uniformity of reference
Type annotations on the right
1/ What is the rationale for dropping reified generics? I don't think you'd find too many Java devs that think type erasure in Java is a positive. I always felt it made generics feel cobbled on in Java
2/ Like the metaclasses.
3/ I prefer the type annotations on the right but think this would be such a massive breaking change as to be impractical without tooling to convert existing code.
4/ constructor initialisation lists
I'm in 2 minds about this. On the one hand I like the separation between setting properties and the constructor body executing.
On the other hand I'm OC with immutable properties and minimise the use of factory constructors as they can't be called by subclasses.
This combination can lead to an explosion of constructors that chain together which gets ugly.
4b/ If you propose getting rid of const does that mean you propose removing annotations?
5/ I no longer use parts and see no great value in them.
6/ Given 4/ above you won't be surprised to learn that I LOVE final by default.
Non null and immutable by default == me very happy
7/ Like Uniformity of reference too. One thing I really liked about Eiffel when I played with it many many moons ago
I feel like "moving off the web" is a stronger statement than that. For people using Dart and targeting browsers, that is a pretty important phrase to just casually slip in there.
On Thu, Sep 3, 2015 at 3:03 PM, Don Olmstead <don.j.o...@gmail.com> wrote:I HATE HATE HATE this. It was actually a huge ick when looking at TypeScript.var name : String; final pi : int = 3; // Close enough. hasTwo(elements : List) : bool => list.length == 2;
With the current Dart syntax, how would you declare a field whose type is a function with some signature?
How would you attach a metadata annotation to the return type of a method, but not the method itself?
On Fri, Sep 4, 2015 at 12:24 AM, 'Bob Nystrom' via Dart Misc <mi...@dartlang.org> wrote:On Thu, Sep 3, 2015 at 3:03 PM, Don Olmstead <don.j.o...@gmail.com> wrote:I HATE HATE HATE this. It was actually a huge ick when looking at TypeScript.var name : String; final pi : int = 3; // Close enough. hasTwo(elements : List) : bool => list.length == 2;
With the current Dart syntax, how would you declare a field whose type is a function with some signature?
> I think the idea is, if you're in an environment like Sky, Dart could have support for cool features like non-local returns.
I feel like "moving off the web" is a stronger statement than that. For people using Dart and targeting browsers, that is a pretty important phrase to just casually slip in there.
whileObject
automatically gets one that returnsfalse
var {
a : int;
b : String;
}
var {
a: int;
b: String;
}
final {
c: num;
d: bol;
}
var a: int;
Reified genericsI don't know the consequences but since Patrice explained to me that `<TypeA,TypeB>{}` is not the same than `new Map<TypeA,TypeB>()` I don't like reified generics much.
Type testswhileObject
automatically gets one that returnsfalse
I would expect object always to return `true` not `false`
Type annotations on the rightI'm not used to this style (never really developed in a language with this style)I feels quite cumbersome. Especially that `var` is necessary in addition to the type everywhere.Something like
var {
a : int;
b : String;
}would easy this pain a lot.
This might even be a solution for (or instead of) final by default
var {
a: int;
b: String;
}
final {
c: num;
d: bol;
}
This is meant in addition to
var a: int;not instead of.
+10 Constructor initialization listsfor moving `super` into the constructor block and treat the statements before `super` like the initializer list but more powerful.
Uniformity of referenceI guess this would be harder to swallow than type annotations on the right.How to differentiate between calling a function referenced by a field and getting the reference to the function?
+1 Removing newI don't care too much, but I find it often cumbersome to differentiate between static methods returning an instance and (factory) constructors.If `const` goes away `new` definitely has to go as well.
Sounds to me mostly as a change for the sake of not looking to Java-like. Couldn't the function type be expressed like such?
class Observable { void() observer; }
--
You received this message because you are subscribed to the Google Groups "Dart Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to core-dev+u...@dartlang.org.
On Fri, Sep 4, 2015 at 10:09 AM, Günter Zöchbauer <gzo...@gmail.com> wrote:Reified genericsI don't know the consequences but since Patrice explained to me that `<TypeA,TypeB>{}` is not the same than `new Map<TypeA,TypeB>()` I don't like reified generics much.I would like to see that explanation - it should be exactly the same.
Type testswhileObject
automatically gets one that returnsfalse
I would expect object always to return `true` not `false`If the "is" method is on the object and takes the type as argument, thenthe default method should use the type of the current object and see if it implements the type represented by the argument. It should neither return always true or always false.
class SomeClass {
SomeClass() {
// initalize finals here;
}
super() {
// further initialization
}
}
Uniformity of referenceI guess this would be harder to swallow than type annotations on the right.How to differentiate between calling a function referenced by a field and getting the reference to the function?Good point. If the "()" is optional, then you can call a nullary function both as a getter "x.foo" and as a function "x.foo()". That means you have two ways to write the same thing, which is not great. It makes "x.foo()" ambiguous - is it calling a nullary function with no arguments and then calling the result, or is it just calling a nullary function.It'll likely be disambiguated to mean calling the method with no arguments, and then you have to write (x.foo)() to call the result of a getter.
Also, should you be allowed to pass zero arguments to a getter?+1 Removing newI don't care too much, but I find it often cumbersome to differentiate between static methods returning an instance and (factory) constructors.If `const` goes away `new` definitely has to go as well.+5.It's still not perfect - a generative constructor is different from any other member because it's necessary for extending a class.Maybe we should drop "extends" from the language, and replace it with auto-delegation.Instead of "class C extends D { something(); }" you do:class C implements D as _d {final D _d;something();}which automatically adds delegates for all members on D to call the same method on _d.Then you don't need to have publicly visible generative constructors at all.
Type annotations on the rightI think that if Dart 2.0 would go in that direction, would the ":" really be needed? I know Go is a different language in many ways but it works for them...Yes, I do understand that it's easier to parse of course, but I feel that it could be parsed without the ":" as well... I can see that the "function as a variable" example might benefit from the ":" for better readability, but for variables (that are way more common), I find it somewhat in the way. It looks almost cumbersome to add types because of the extra typing, I might grow to like it, I don't know, but I don't really like looking at it right now..I would not go as far as to say that I "HATE HATE HATE this" hehe, but I agree that it does look almost plain weird for normal vars and I think it would be off putting to a lot of devs... Some of you core language people might not really see this as you guys have seen so many different syntaxes, it's not that different if you have seen it before yourself, but lots of devs have never ever seen this type of syntax, where as I feel "just moving the type to the right" is a lot less unfamiliar. Sure any dev could get used to it, but Dart right now wants to add lots of new users not just adapt the existing ones...
On Thu, Sep 3, 2015 at 3:07 PM, Kasper Peulen <kasper...@gmail.com> wrote:> The portion of the Dart team that comes from a Smalltalk background has long missed non-local returns. The stated reason for > not having them is that no one knows how to efficiently compile them to a language like JS which lacks them. *If our focus is> moving off the web towards execution environments we control,* Gilad would like to put them back on the table.What do you guys mean with "dart moving off the web" ? Would this non local returns also available when you compile to javascript ?I think the idea is, if you're in an environment like Sky, Dart could have support for cool features like non-local returns.
On Friday, September 4, 2015 at 10:35:43 AM UTC+2, Lasse Reichstein Holst Nielsen wrote:On Fri, Sep 4, 2015 at 10:09 AM, Günter Zöchbauer <gzo...@gmail.com> wrote:Reified genericsI don't know the consequences but since Patrice explained to me that `<TypeA,TypeB>{}` is not the same than `new Map<TypeA,TypeB>()` I don't like reified generics much.I would like to see that explanation - it should be exactly the same.It's quite some time back, I guess it was a discussion on some Angular issue.AFAIR he mentioned `<TypeA,TypeB>{}` doesn't doesn't reify generic arguments. If you say it's the same I believe you of course ;-) and will have a better rest at night from now on.
Map<A,B> m = {}
Map<A,B> m = <A,B>{}
On Fri, Sep 4, 2015 at 12:24 AM, 'Bob Nystrom' via Dart Misc <mi...@dartlang.org> wrote:On Thu, Sep 3, 2015 at 3:03 PM, Don Olmstead <don.j.o...@gmail.com> wrote:I HATE HATE HATE this. It was actually a huge ick when looking at TypeScript.var name : String; final pi : int = 3; // Close enough. hasTwo(elements : List) : bool => list.length == 2;
With the current Dart syntax, how would you declare a field whose type is a function with some signature?int->int x;(int,int)->int x;(int,int)->(int)->int foo(int->int f1, int->int f2) => (int x1, int x2) => (int x) => f1(x+x1) + f2(x+x2)I don't think this is ambiguous in any way ('-' followed by '>' is currently only possible using suffix '--'), but it will complicate the parsers. My guess is that more look-ahead will likely be needed.We have avoided introducing function type literals, but that's a choice, not a necessity.I'm sure other syntaxes are also possible, perhapse even ones that look more "C like":int(int)int(int,int)int(int)(int,int)That said, ':' is just a much more convenient syntax.
// Simple type
Point p = Point(1,1);
// Complex type - needs a leading var/const on locals only
var Point | Line x;
var int Call(int, int) fn;
Maybe we should drop "extends" from the language, and replace it with auto-delegation.Instead of "class C extends D { something(); }" you do:class C implements D as _d {final D _d;something();}which automatically adds delegates for all members on D to call the same method on _d.Then you don't need to have publicly visible generative constructors at all.
... I was quite confused about Dart type annotations back then - even more than now ;-)
Thanks for clarification and sorry for accusing you of making invalid statements!
--
You received this message because you are subscribed to the Google Groups "Dart Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to core-dev+u...@dartlang.org.
On Thu, Sep 3, 2015 at 3:03 PM, Don Olmstead <don.j.o...@gmail.com> wrote:I HATE HATE HATE this. It was actually a huge ick when looking at TypeScript.var name : String; final pi : int = 3; // Close enough. hasTwo(elements : List) : bool => list.length == 2;
With the current Dart syntax, how would you declare a field whose type is a function with some signature?
class Observable {
void() observer;
// or:
function<void()> observer;
}
How would you attach a metadata annotation to the return type of a method, but not the method itself?
class X {
}
class Y {
@NonNull X someMethod();
}
// normal return
return 'foo';
// non-local return
^return 'foo';
> I think the idea is, if you're in an environment like Sky, Dart could have support for cool features like non-local returns.
I feel like "moving off the web" is a stronger statement than that. For people using Dart and targeting browsers, that is a pretty important phrase to just casually slip in there.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
More useful Enums (by which I mean ability to add values like print(myEnum.ThirdPlanet); //earth
Swift's code looks cleaner than Dart's and avoids clutter. Notably, it avoids semi-colons and doesn't use round brackets in for loops, switch statements and if blocks. Swift also has some nice syntax sugar e.g. you can say "for n in 0..<10 {" which in Dart is "for (int n=0;n<10;n++) {"Any chance of some of that goodness?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
> "for n in 0..<10"Why not justfor (int n<10) {...}The case is very common; if something deserves special syntax, this is the first candidate. Will become an instant hit.
Current syntax (borrowed all the way from C) is error-prone, especially if you have nested "for" loops: you copy&paste the first one and forget to change i to j somewhere.When you (rarely) need a general case, use full syntax - it will also serve as indication that something unusual is going on here.
--
Here's my notes from this week's now hour long meeting:I mention this in the notes, but I want to call it out here. We're starting to discuss this vague notion of "Dart 2.0". We don't know what that means yet, and that means we'll be talking about all kinds of crazy radical ideas which may or may not come to pass.
Why not justfor (int n<10) {...}
> Dart doesn't have a notion of "package", "package" is from pub instead.Effectively, there's a notion of package anyway. E.g. latest proposal on "packages" config deals with instructions to compiler on how to locate ... what?.
Map<String, StreamSubscription> subscriptions;// Do something then instead of
// subscriptions.values.forEach((sub) => sub.cancel());
subscriptions.values.forEach(::cancel());
On Sun, Sep 13, 2015 at 5:56 PM, tatumizer-v0.2 <tatu...@gmail.com> wrote:> Dart doesn't have a notion of "package", "package" is from pub instead.Effectively, there's a notion of package anyway. E.g. latest proposal on "packages" config deals with instructions to compiler on how to locate ... what?.Dart doesn't have the notion of "same package". It resolves package: URIs to something and loads the individual libraries, but it doesn't have a concept of things being in the same package or not. That is, it doesn't know what "a package" is, just that there is "something package related" that it can load.It's not hard to add - it's just checking whether the first path segment is the same - so if it makes sense to add some kind of "package privacy" to Dart, then it's definitely doable. It's just not necessarily a very good design since it only works for packages, it depends on *how* a file is imported (using a file: reference to a Dart file instead of a package: reference would make things break?), and not all Dart files come from packages (for example the dart: platform libraries don't).A shared private namespace might make sense, but I don't think only applying it to packages is a good idea./L 'And I want "protected" first!'
theFuture as void;currently, it's not a valid expression, not clear why.
@Lasse:
> A shared private namespace might make sense
I looked into C# definition of namespaces (https://msdn.microsoft.com/en-us/library/z2kcy19k.aspx plus links from there) - it's complicated! (there are links from main page leading to explanations of various aspects involved).
At some point, namespaces were all the rage, maybe because XML had them (it was an important nail to the coffin of the concept)
Turning each package into de-facto namespace looks like much simpler solution to me. Just remove "part" directive, let everything in the package see everything else, this automatically allows access to private methods from tests... It's much easier to formalize the notion of "package" than to go into "namespaces" rat hole IMO.
For protected methods - I am not sure. Maybe, if B extends A, then B should be able to *override* every method of B, including private ones (e.g. with @override annotation)?
On Mon, Sep 14, 2015 at 8:05 PM, tatumizer-v0.2 <tatu...@gmail.com> wrote:@Lasse:
> A shared private namespace might make sense
I looked into C# definition of namespaces (https://msdn.microsoft.com/en-us/library/z2kcy19k.aspx plus links from there) - it's complicated! (there are links from main page leading to explanations of various aspects involved).Ack, yes. That's more complicated. All I intended was that two libraries may be allowed to have compatible private names.Dart private names are unique per library - it's not an access restriction that prevents you from accessing "_foo" declared in a different library, it's an expressibility restriction: You can't *write* the same _foo as the other library.If we had a way to link two libraries in such a way that their private names were compatible, then writing "_foo" in either library refers to the same name.
Turning each package into de-facto namespace looks like much simpler solution to me. Just remove "part" directive, let everything in the package see everything else, this automatically allows access to private methods from tests... It's much easier to formalize the notion of "package" than to go into "namespaces" rat hole IMO.Are you suggesting that "_foo" means the same for libraries loaded using a package: URI if the first path segment of the path is the same?I still have reservations against that, mainly that it only works for packages, which isn't good enough. I'd rather be able to have any two(or more) libraries able to opt into having a common privacy instead of per-library privacy.
Also library privacy prevents you from even expressing which superclass method you are overriding. Just writing "@override int _foo() =>42;" won't tell you which "_foo" it is. There may be two different private names originally written "_foo" in the superclass chain, from different libraries.To solve the problem, I think we need some kine of "object privacy" where you can refer to such a name only on the same object (perhaps only through "this." or "super."). It's a different kind of name from library private and public names.
library some_lib;
part 'some_lib_impl.dart';
part 'some_lib_extra.dart';
/// Lots of comments, examples...
// Stable public interface
abstract class SomeClass {
factory SomeClass() => new _SomeClassImpl();
}
part of some_lib
// implementation with lots of private functions,
// abstract private base classes, mixins, etc
class _SomeClassImpl extends _SomeClassBase implements SomeClass {
_SomeClassImpl();
}
abstract class _SomeClassBase {}
part of some_lib
// several hundred of numbers such as primes, decode constants, etc
const List<int> _data = const [0x1, 0x3, 0x5, ...];
There is one more issue with removing 'part' directive. It will be impossible to implement rather common Dart pattern (found in dart:io and some pub packages e.g. crypto).
// some_lib.dartlibrary some_lib;import 'some_lib_impl.dart';import 'some_lib_extra.dart';
/// Lots of comments, examples...// Stable public interfaceabstract class SomeClass {
factory SomeClass() => new SomeClassImpl();}// some_lib_impl.dart
// implementation with lots of private functions,// abstract private base classes, mixins, etc
class SomeClassImpl extends _SomeClassBase implements SomeClass {SomeClassImpl();}abstract class _SomeClassBase {}// some_lib_extra.dart
// several hundred of numbers such as primes, decode constants, etc
const List<int> data = const [0x1, 0x3, 0x5, ...];
Moreover, I see no reason to call each of these three files a 'library', because they are useless one by one.
On Tue, Sep 15, 2015 at 1:21 AM, 'Lasse R.H. Nielsen' via Dart Misc <mi...@dartlang.org> wrote:On Mon, Sep 14, 2015 at 8:05 PM, tatumizer-v0.2 <tatu...@gmail.com> wrote:@Lasse:
> A shared private namespace might make sense
I looked into C# definition of namespaces (https://msdn.microsoft.com/en-us/library/z2kcy19k.aspx plus links from there) - it's complicated! (there are links from main page leading to explanations of various aspects involved).Ack, yes. That's more complicated. All I intended was that two libraries may be allowed to have compatible private names.Dart private names are unique per library - it's not an access restriction that prevents you from accessing "_foo" declared in a different library, it's an expressibility restriction: You can't *write* the same _foo as the other library.If we had a way to link two libraries in such a way that their private names were compatible, then writing "_foo" in either library refers to the same name.I'd like something along these lines too. I talked about it with Leaf once, and he brought up a tricky case. What would it mean to define a new top level private name in the friend library? Would that name appear in the source library too?
I think there probably is a clean solution, but it might be more complex than I initially thought.
Also library privacy prevents you from even expressing which superclass method you are overriding. Just writing "@override int _foo() =>42;" won't tell you which "_foo" it is. There may be two different private names originally written "_foo" in the superclass chain, from different libraries.To solve the problem, I think we need some kine of "object privacy" where you can refer to such a name only on the same object (perhaps only through "this." or "super."). It's a different kind of name from library private and public names.
I like Ruby's solution: private methods can only be invoked with the implicit self receiver.
break
, continue
, and labels in favor of non-local returnsnew
> I'd introduce ranges instead, then you could write:> for (int n in [:10]) { ... }This is exactly what I tried to avoid in my bold proposal. 99+% of all uses of ranges will likely occur in for statement anyway, just creating noise.Ranges might be an orthogonal idea that is worth considering, but it's (statistically) second or third tier feature IMOI think this is another example of logic: I need feature X, but Y is more general so I provide Y, thus killing two stones with one bird..This reasoning doesn't account for statistics of usage.
I'd like something along these lines too. I talked about it with Leaf once, and he brought up a tricky case. What would it mean to define a new top level private name in the friend library? Would that name appear in the source library too?No, no more than if both libraries declared a public name like "foo".It should still be two different libraries, it's just that the name-mangling of private names creates the same mangled name for "_foo" in both libraries, so if one does "otherLibraryClass._private", it actually works.
I think there probably is a clean solution, but it might be more complex than I initially thought.I'm not sure the implementation is complex. Specifying it, and picking the right restrictions on who can declare themselves friends, is harder. It should be a mutual agreement between the libraries, so you can't just say "I'm friends with that guy, so I get to look at his private stuff". It's an agreement between cooperating libraries that they can access each other, not a privacy override. At least, that's what I want :)
Also library privacy prevents you from even expressing which superclass method you are overriding. Just writing "@override int _foo() =>42;" won't tell you which "_foo" it is. There may be two different private names originally written "_foo" in the superclass chain, from different libraries.To solve the problem, I think we need some kine of "object privacy" where you can refer to such a name only on the same object (perhaps only through "this." or "super."). It's a different kind of name from library private and public names.
I like Ruby's solution: private methods can only be invoked with the implicit self receiver.Yep, that's what I'd want too. In Dart, we'd need a third kind of identifier for it.It's a type of identifier that only makes sense for instance members, which is new.
The member is only part of the class, not its interface - implementing the class won't include it, but extending it will.
The question is whether we need variables that are both object-private and library-private at the same time.Something available only to subclasses in the same library.I guess you could just use library-private in that case, since you are assumed to trust your own library.
For API documentation, the "protected" members would need to be documented - they are publicly visible, just only through this/super.
Removebreak
,continue
, and labels in favor of non-local returns
I see no good reason to remove "break" and "continue".
I would keep them.
Parts
Please remove parts.
Removing new
Of course.
Removing Reified generics
Type annotations on the right
Fields final by default
Assert
Uniformity of reference
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Parts
Please remove parts.I can see the benefit of keeping parts, splitting a large file into separate parts, but then one can also argue that those separate files should be separate classes / libraries. Using parts is somewhat confusing at times, especially when forgetting either the part section or importing it in the main file and code misbehaving. How would the export alternative work?
Removingnew
Of course.Making it optional would be much better, although deprecating the new keyword would be less harsh if it is removed followed by permanent removal at a later stage in Dart 3.
Fields final by defaultvoid updateABC(String abcNumber, SomeIdentifier abcIdentifier, e) { ...If I understand this correctly, making fields final refers to making parameters final in functions or does is spread wider?If parameters are final, does that mean in the above example I can't go abcNumber = "3" inside the function,neither abcIdentifier = new SomeIdentifier(), but I can do abcIdentifier.a = 1; abcIdentifer.b = 2; like in java asif each variable was defined final String abcNumber, final SomeIdentifier abcIdentifier.Would there be use cases where params are expected not to be final for some reason?In Java projects I see people treat parameters as final in any case whether they are marked as final or not.
Fields final by default
void updateABC(String abcNumber, SomeIdentifier abcIdentifier, e) { ...
If I understand this correctly, making fields final refers to making parameters final in functions or does is spread wider?
If parameters are final, does that mean in the above example I can't go abcNumber = "3" inside the function,
neither abcIdentifier = new SomeIdentifier(), but I can do abcIdentifier.a = 1; abcIdentifer.b = 2; like in java as
if each variable was defined final String abcNumber, final SomeIdentifier abcIdentifier.
Would there be use cases where params are expected not to be final for some reason?
In Java projects I see people treat parameters as final in any case whether they are marked as final or not.
AFAIU, class fields are meant.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Fields final by default
void updateABC(String abcNumber, SomeIdentifier abcIdentifier, e) { ...
If I understand this correctly, making fields final refers to making parameters final in functions or does is spread wider?
If parameters are final, does that mean in the above example I can't go abcNumber = "3" inside the function,
neither abcIdentifier = new SomeIdentifier(), but I can do abcIdentifier.a = 1; abcIdentifer.b = 2; like in java as
if each variable was defined final String abcNumber, final SomeIdentifier abcIdentifier.
Would there be use cases where params are expected not to be final for some reason?
In Java projects I see people treat parameters as final in any case whether they are marked as final or not.AFAIU, class fields are meant.If all fields in a class are final, how do you modify those fields outside the constructor ?How would you make them non-final so you can actually use them ?
What would be the reasoning to make all fields final by default?Isn't that less efficient to create a new instance every time you want to change a value?
99.99% of fields I create in a class I use in a non-final context, example, using setters.
I agree, for fields this would be cumbersome but it would be convenient for variables and parameters.
While we are talking about Dart 2.0 stuff, how about adding a @protected (and @private instead of '_') annotation, honored by DartAnalyzer etc?
Frankly, I don't understand the rationale for "protected" methods. If you want something to be part of public interface- use public methods. Otherwise make them private. The notion of something accessible only from subclasses looks arbitrary. What about mixins? Can mixin access protected method from its host? What about delegation?
FancyButton f = ...;f. <-- autocomplete popup here
Further, if you make anything "protected", Alice can always extend your class with the only goal of effectively making your protected method freely available to all her code, e.g. via a method with different name.
Anyway, if someone knows a use case for @protected, it can be done via annotation for public method - this annotation can be interpreted by human, and/or tools outside of compiler. For compiler, it's a normal public method IMO.P.S. See discussion here
"protected methods" are an API design feature, not a security feature.
--
You received this message because you are subscribed to the Google Groups "Dart Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to core-dev+u...@dartlang.org.