Skip to content

Type Annotation Syntax On The Right. Use of def, var and val in lieu of var, T x, final x.  #56

Closed
@DartBot

Description

@DartBot

This issue was originally filed by Ray.Rac...@gmail.com


What steps will reproduce the problem?
1.Write Dart code as proposed.
2.
3.

What is the expected output? What do you see instead?
Optional type annotation to be on the right of the identifier. Use of val to replace final and def to denote the start of a method/function definition.

What version of the product are you using? On what operating system?
All

Please provide any additional information below.

  1. Use of the type annotation on the right allows for better readability and more importantly positions Dart to more easily handle future syntax extension and language evolution. Dart language designers know the pros / cons here already.

val x Int = 3
var y String = 'Gilad'
def rev (s String)String => s.reverse ()

  1. Use of val of final is more intuitive, pithy aligns code nicely with var and def.

  2. Placing the type on the right supports (requires) the use of a keyword to denote a method / function definition. Use of 'def' is suggested.

Primary Reason Not to Change.


The stated reason to keeping type annotations on the left is familiarity for the mainstream programmer as (I assume) many of the new Dart new comers will be from C#, Java.

  1. There are as many non-Java people coming to Dart who will not have any basis. Those from JS, Ruby, Python will be familiar with 'def' for example.

  2. Universally Java/C# people coming to Scala have been positive with this syntax as cleaner and enhancing readability. (Scala adoption issues center on the complex type system and not its base declaration syntax).

  3. It is apparent that Dart has been painted, unfairly, as "its just Java". These small syntax changes,off a sense of "freshness" to the Dart language that will soon be appreciated by new comers.

Adaption has shown the barrier to new syntax is very low barrier and immediately appreciated by the majority of Java users for its basic elegance and cleaness.

People will be much more receptive to Dart from such a sense "newness" and "freshness" about it from such minor syntax cleanups yet retains all the core familiar concepts.

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-not-plannedClosed as we don't intend to take action on the reported issuetype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions