Post by Günter ZöchbauerRemove break, continue, and labels in favor of non-local returns
I see no good reason to remove "break" and "continue".
I would keep them.
How do you jump out of a loop or continue to the next iteration without
break / continue ?
Typical Java example when polling something:
while (true) {
if (canDoSomething()){
break;
}
sleep(1000);
}
+1 for keeping them, unless the alternative is much much much better.
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?
Removing new
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.
Removing Reified generics
What would be the reason for removing it?
I'm assuming reified generics has something to do with maintaining type
information after compilation as opposed to erasure.
Java is using TypeErasure for the sake of backwards compatibility, one
would assume that there are plenty of benefits for keeping type information?
Type annotations on the right
I can see the benefit of it after doing plenty of reading and it will
probably take a lot to get used to.
Seeing as other breaking changes are also being considered, may I suggest
that you rather go for deprecating the old syntax for Dart2, introducing
the new syntax in Dart2 and completely removing the deprecated syntax in
Dart3.
Also, if you're planning to go RHS, instead of *var pi : int = 3*, rather
make the var keyword optional, so if it's not supplied, it's implied that
it's a var.
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.
Assert
I've never seen the benefit of assert in Java, assert is disabled by
default unless you enable it with special flags and unit tests have their
own
Assert.assertTrue, Assert.assertEquals, etc.
Writing my own assert function that behaves exactly as I want it sounds
much more useful.
+1 for deprecating assert unless it has some very useful usecase.
Uniformity of reference
Removing () for 0 param functions would make code very confusing to read, I
would not be sure whether I'm looking at variables or functions.
Take words that are nouns and verbs as example:
object. address <- is this the object's address or does it mean address the
issue
object.display <- does this mean display object or is it a boolean flag
being set for when the object can be displayed.
-1 for removing () from 0 param functions.
--
Jan Vladimir Mostert
janvladimirmostert.com
On Wed, Sep 16, 2015 at 9:37 PM, 'Bob Nystrom' via Dart Misc <
Post by Günter ZöchbauerOn Tue, Sep 15, 2015 at 11:24 PM, 'Lasse R.H. Nielsen' via Dart Misc <
Post by 'Lasse R.H. Nielsen' via Dart MiscPost by 'Bob Nystrom' via Dart MiscI'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.
OK, I *think* that makes sense, though I haven't really sat down to work
through all the implications.
Post by 'Lasse R.H. Nielsen' via Dart MiscPost by 'Bob Nystrom' via Dart MiscI 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 :)
I personally lean towards it being less restrictive. One use case for this
is tests, and I don't want non-test library code to mention its tests in
any way, even if just to say "I allow this test to access my private stuff."
Privacy is a developer productivity feature, not a security feature, so I
like "velvet rope" privacy. It tells you when you're going outside of the
bounds of the public API, but allows you to if you really know what you're
doing.
Being *too* restrictive can end up lowering productivity if you prevent a
user from doing something reasonable.
Post by 'Lasse R.H. Nielsen' via Dart MiscPost by 'Bob Nystrom' via Dart MiscPost by 'Lasse R.H. Nielsen' via Dart MiscAlso library privacy prevents you from even expressing which superclass
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.
I haven't put much thought into this, but I don't know if we need a
different identifier style that the user sees. I think we could just treat
self-sends as being implicitly name-mangled in some way.
Post by 'Lasse R.H. Nielsen' via Dart MiscThe member is only part of the class, not its interface - implementing
the class won't include it, but extending it will.
+1.
Post by 'Lasse R.H. Nielsen' via Dart MiscThe 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.
Yeah, I think library private is perfectly adequate for this.
Post by 'Lasse R.H. Nielsen' via Dart MiscFor API documentation, the "protected" members would need to be
documented - they are publicly visible, just only through this/super.
Yup.
Cheers!
- bob
--
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
--
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+***@dartlang.org.