--
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 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'm not sure about the other suggestions, but I definitely agree with the postfix instead of prefix type annotations. It just makes actually *reading* code flow a lot smoother -- all your variables and methods line up nicely against the left margin, making it easy to spot what you're looking for with a single smooth vertical eye motion.
Coming from a C++ background, I disagree on this one and prefer dart's current type annotation syntax. For me, the most important information I need to know when analyzing code is the types, not the user provided name.
--
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.
Rua Olimpiadas, 194 - 2º/8º/9º/13º Andares
Vila Olímpia - São Paulo / SP - Brasil
Cep: 04551-000
Tel.: + 55 11 3028-9800
Fax: + 55 11 3028-9842
marcelo@brasfond.com.br
www.brasfond.com.br
2. 'let' not 'final' for immutable locals
4. type annotation syntax either:
a) test(int a) -> int { // code }
b) test(a:int):int { // code }
5. shorthand syntax for POD's
class Point(int x, int y);
- Make "new" optional.- Make "const" be an expression modifier, not a constructor call modifier, and inside the expression, all map and list literals are automatically const, and all constructor calls are also const invocations ("new" is not allowed, extra const prefixes are ok if you want them, so this is backwards compatible).
- Introduce null-guard, e.g. x ?? y meaning (tmp=x) != null ? tmp : y- Maybe introduce null-guarded operations: x.?foo(y) is null if x is null (but does evaluate y).- Enums (enum { X,Y,Z} just expands to integer constants and enum Foo {X,Y,Z} to an enum class with constants Foo.X,...)- Allow '=' for the default values of named parameters. It's foo([x = 4]) but foo({x : 4}. I keep having to fix that. Looking like map syntax isn't clever.- Introduce strict type annotations: Foo! foo(Foo x) => x ?? new Foo(42); This is like the type annotation "Foo", except that it doesn't accept "null" as well. (Yes, Null! would accept null :)And something that can't be done by just a preprocessor:- Type parameters on functions/generic functions.- Allow both optional positional and named parameters on the same function.
2. 'let' not 'final' for immutable localsI would love this, I guess it's to late now :(
4. type annotation syntax either:
a) test(int a) -> int { // code }
b) test(a:int):int { // code }Too late for that.5. shorthand syntax for POD's
class Point(int x, int y);I would love to see this.
--
--
|
--
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.
My personal preference? Leave it as it is.
That said, Dart has been accepted into the standardization body ECMA TC52 [1]. you will need to petition that working body for such language changes not Google. They have already stated that further language changes and enhancements will be deferred to that body rather than tackled at this point.Many of your proposed changes do not enhance the language any yourself nor provide significant benefits in terms of productivity or performance of the tools and really cannot be justified beyond 'your personal preference', which of course we're all entitled to have. However for myself, those changes make the language less familiar to me, and one of the stated goals of Dart was to be familiar. (let for instance is a block-scope variable in Javascript, not a final variable, in C# it's kind of final, but for query expressions only.)
My biggest grouch is that omitting the type annotations on locals makes them dynamic rather than inferred. I would have much preferred being forced to have to use the dynamic keyword explicitly.
As it stands now you can completely stuff up your code and won't see it till you run a unit test. That's why most of my locals have type annotations now and as someone pointed out my code bloats cos I also add final to them.
Would love to see warnings in the editor and linter on these. If dart aims to improve code quality to that of js then IMO this is a must have
My 2c
exactly my experience
Totally agree we enums and deeply immutable objects. But let vs final etc is not worth it IMO nor is dropping new. Just too small a gain for me
--
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.
My biggest grouch is that omitting the type annotations on locals makes them dynamic rather than inferred. I would have much preferred being forced to have to use the dynamic keyword explicitly.
<< leave the language as just the basis for simple and expressive semantics, than supporting special cases for Group A or BWhat do you mean by support ? Macros ?
For source code related features, I prefer having a standard instead of countless do-it-yourself variants.
And macros can evolve into DSL languages which means additional effort to maintain and to learn as employee.
On the other hand, I would welcome if Dart (and libraries) would become a simple target platform for compiled and interpreted languages.
Short, flexible and efficient but not cryptic syntax matters much to me.Dart is quite good so far. Much better than Javascript.
Classes serve as namespaces or modules as well.So "static" has some use cases except for "static const name = ...".
although last time I looked at it, the import didn't have a way of refining the names to be included in the namespace, such as Clojure has
class Person {
int age;
String name;
}
void foo() {
var p = new Person();
p = 6;
}
void fum() {
Person p = new Person();
p = 6;
}
dynamic p = new Person();
Option<Person> fooPerson() { }
void fumPerson(Person p) {}
void blah() {
final p = fooPerson();
fumPerson(p); // no warning!!!!!
fumPerson(fooPerson); // do get warning
I don't think you can rename an individual identifier.
For me it would be extremely rare that I would have actually wanted to have p be dynamic. So for those rare (for me) cases I would prefer to have to do
My biggest grouch is that omitting the type annotations on locals makes them dynamic rather than inferred. I would have much preferred being forced to have to use the dynamic keyword explicitly.
Yeah I think any changes should provide major value rather than be a synonym for something existing.
My personal wish-list for syntax improvements:- Make "new" optional.- Make "const" be an expression modifier, not a constructor call modifier, and inside the expression, all map and list literals are automatically const, and all constructor calls are also const invocations ("new" is not allowed, extra const prefixes are ok if you want them, so this is backwards compatible).- Introduce null-guard, e.g. x ?? y meaning (tmp=x) != null ? tmp : y- Maybe introduce null-guarded operations: x.?foo(y) is null if x is null (but does evaluate y).- Enums (enum { X,Y,Z} just expands to integer constants and enum Foo {X,Y,Z} to an enum class with constants Foo.X,...)- Allow '=' for the default values of named parameters. It's foo([x = 4]) but foo({x : 4}. I keep having to fix that. Looking like map syntax isn't clever.- Introduce strict type annotations: Foo! foo(Foo x) => x ?? new Foo(42); This is like the type annotation "Foo", except that it doesn't accept "null" as well. (Yes, Null! would accept null :)And something that can't be done by just a preprocessor:- Type parameters on functions/generic functions.- Allow both optional positional and named parameters on the same function./L
--
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.
--
Lasse R.H. Nielsen - l...@google.com'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - Denmark - CVR nr. 28 86 69 84
List shapes = []; // Use literals to create lists.
On Feb 9, 2014 8:48 AM, "kc" <kevin...@gmail.com> wrote:
>
> In a recent presentation on Dart (http://www.infoq.com/presentations/dart-motivation-future), the section 'Optional Types' beginning at 23:25 has an accompanying slide displaying:
>
> "Checked Mode ... Creates a language that *does* require types :-("
>
I don't think that is correct, and I'll discuss it in person with Gilad and report back.
The gist of my objection to that statement is that types aren't required, but when you use them, they must match.
This creates problems for proxy classes which is why I have always argued that the is operator should be user definable.
> Thus, examples from the dartlang site often contain explicit type annotations which could easily be inferred e.g. from the subsection 'Concise' with the byline: 'Write less. Say more.':
>
> List shapes = []; // Use literals to create lists.
>
I think you miss the point of this example: by including the type, the example documents what the type of the literal is.
Cheers,
Peter
> But developers may respond:
>
> https://twitter.com/rich_4711/status/428092733236842497
>
> Especially those with a scripting/functional/type inference language background. The Java-ish boilerplate will turn them off - which is a shame.
>
> (n.b. C style type annotation syntax and type inference ambiguity re 'var' possibly contribute to excessive type annotation as well as checked mode).
>
> K.
>
>
> On Thursday, January 30, 2014 3:40:47 PM UTC, kc wrote:
>>
>> OK - I don't think any of these will happen ... but I want to express this:
>>
>> A lot of these suggestion are related to Dart's type annotation story.
>>
>> From the 'Type Annotation' secton in the 'Dart Style Guide':
>>
>> PREFER providing type annotations on public APIs.#
>> PREFER using var without a type annotation for local variables.#
>> AVOID annotating with dynamic when not required.
>>
>> This is what I'm looking for. Basically a great set of publicly available libs with type annotations. Gives me code completion and type inference in my apps. My non-public app code wil be pretty much be type annotation free.
>>
>> But for public API's in published libs maybe explicitly typing with 'Any' aka 'dynamic' is a better way to go. (dynamic is from c# but c# was trying to lighten itself coming from a static heavy direction via the .net vm. Whereas Dart is coming from the opposite direction of a Smalltalk inspired OO dynamic runtime).
>>
>> But currently developers are saying 'I would like to use type inference - but feel it's safer to type annotate everything'.
>> And if the local is immutable then:
>> final Point p = new Point(1,1); // yuk
>>
>> If developers go-to-town with types then imo the dynamic OO story of Dart becomes too brittle and ceases to work.
>>
>> But with a rejigged type annotation syntax it should be much easy to express union types (for types that don't have a common ancestor) which should lessen the usage of 'Any' aka 'dynamic' on public API's:
>> test(cat|frog creature)-> cat|dinosaur { // code };
>> test(creature: cat|frog): cat|dinosaur { // code };
>>
>> And ideally the static type annotation part of the language spec should be removed to a separate document/spec so the type inference story can evolve separately via developer experience. With the ability of dial up and dial down the static type experience. As opposed to a strait jacket which encourages developers to type annotate everything rather than just public api's. And the place to offer this developer friendly experience is ... Spark.
>>
>> K.
>
> Thus, examples from the dartlang site often contain explicit type annotations which could easily be inferred e.g. from the subsection 'Concise' with the byline: 'Write less. Say more.':
>
> List shapes = []; // Use literals to create lists.
>I think you miss the point of this example: by including the type, the example documents what the type of the literal is.
Point a = new Point(2, 15);
Point b = new Point(7, 3);
Good point. I've been annoyed by javaisms like that as well.
You could file a bug or send them a patch :-)
Cheers,
Peter
--
Good point. I've been annoyed by javaisms like that as well.
You could file a bug or send them a patch :-)
The darlang site's front page examples all seem to explicitly type annotate on locals. 'var' is not used.
My question is why? Why was the style guide not followed - especially given that the examples were written by a Dart team member.
In short I use the cool iterable methods like map, fold, where etc a lot. Partly that may be me taking out my frustrations of javas lack of lambda support out on dart, but mostly because I really like programming that way.Unfortunately, due to the lack of generic types on methods (https://code.google.com/p/dart/issues/detail?id=254) the map method (and fold, expand etc) is defined asIterable map(f(E element));i.e. you jump from a typed iterable to a dynamic one so at this point you may as well be coding javascript cause the editor is not going to help you. e.g
Since only 102 people have starred https://code.google.com/p/dart/issues/detail?id=254 I'm guessing most people don't use map much or haven't realised how that issue completely destroys all the awesome work the editor team has done with hints if you use it.
Idiomatic Dart code does use a bunch of transformers on sequences (and streams and futures) and those indeed throw a lot of auto-complete out the window right now. :(
--
Just tripped over another interesting one
--
In fact it makes some aspects of idiomatic dart at odds w the style guide IMO
And +1 for the missing return fix. That's a biggie for me so greatly appreciated.
Some us will have to just agree to disagree on some of these style issues. Personally, I find local type annotations make code more readable for me, as I am accustomed to read things from left to right.
Why do you think the industry is moving away from local type annotations?
--
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.
Why do you think the industry is moving away from local type annotations?Because in most langauges (with the exception of Dart *) these are totally redundant, leading to extra typing and extra time for a programmer to read.
+1
On Mon, Feb 10, 2014 at 3:08 PM, Anders Holmgren <andersm...@gmail.com> wrote:
If we don't write code the way we want to, the tools will never grow to accommodate that style. Why would the analyzer folks spend the time to implement any type inference if everyone was fully annotating everything?
It's the job of tooling to make your life easier. It's not your job to make the tool's life easier. That does mean that there are times where there's lag between your ideal style and what the tool supports most gracefully, but I think if you are patient during that lag, in return you get tooling that does more work for you.
Given that I wrote both of those documents, I hope that isn't the case!
- bob
"var" meaning "dynamic" also breaks the principle of uniformity: if it's fully synonymous with "dynamic", why another name? If it's not synonymous, what's the difference? If could mean "inferred", but the notion of inferred type was not developed into consistent concept, as examples in the discussion thread indicate.
I would like to have this too:
- var => Tells the tools that static type safety is required. This enables errors and type based change of identifiers.
- dynamic or any => Declares dynamic as type.
If there is any way to change the spec, I would like to have a referendum about that change.
Am Mittwoch, 12. Februar 2014 07:19:26 UTC+1 schrieb kc:
--
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 am fine with your proposition.
But I do not understand your concern about the VM.
Tools are free to add whatever help and type constraints are wanted.
That the VM does not need type declarations is awesome.
I thought that a loose relationship between VM, compiler and tools was a goal for Dart.
Are you thinking about code generation at runtime without static tool checks ?
I do not know how that will turn in Dart.
My guess is that the VM uses already type information, type constraints and type checks all the time.
Sorry, i still do not understand.
AFAIK:
1)
The purpose of static types is to avoid that the following can be compiled :x := 42;x = "something";
Static types mean whole program checks.
Therefore my remark about dynamic code generation.
2)
I feel ridiculous to tell you about the VM but judging from my test,
the Dart VM seems to use types and does dynamic type checks.
For example:
- The use of "as".
- When trying to call some function from a variable that has the wrong type. E.g. B x = new A();
That was my thoughts when I read that too but dart's type system is not what I (and many others from a statically typed background) are used to (see https://www.dartlang.org/articles/why-dart-types/)
My *personal* view is that the type system really should be external to the language and entirely managed by tools. In Dart we chose differently - the type system interacts with the runtime in checked mode and this has important benefits and some drawbacks. Dart does not really support pluggable types - it's only taken 20 years to get optional types, so stay tuned ....
Personally I would be happy with tools that provide "hints" by doing type inferencing and leave it out of the VM if that simplifies things. Anything that helps me catch most of the simple errors up front would be a big help.
People from a dynamic background would probably not want to see those hints so I suspect they need to be configurable. You would likely end up with people using the tools quite differently. People like me would dial up the type checking hints. I'd even like to be able to turn on contravariant return type checking to flag the foo example above, but I guess that's pushing it ;-)
Any advice?
do you think it's ok with lowercase?
--
I think, I'm leaning towards your suggestion. I better relax the rules. No "return". Just call "done(42)" at any point - it will create the object as if "new Command.done(42)" is called, and memorize it. After function returns, I will execute the command. Certain restrictions may (or may not) apply (e.g. just a single command can be placed in the buffer). In other words, it will be treated as "scheduleCommand".
But still, I think the problem is broader than my immediate needs. There should be naming convention or something about such delayed actions, at least for readability. Maybe there are precedents already, I'm just not aware of them. In java, people introduce a lot of classes like "MaximizeAction", "TextSizeAction", etc. but this style doesn't fit in dart at all IMO.
--
Matthew,I meant that with "new" keyword optional, I could create classes named Done, Cancel, etc, and say simply return Done(42). which would be as dartish as it gets.The whole point was that "new" stands in the way of good writing, be it English writing or otherwise.