IssueRaiser

Import shorthand syntax

Most recent version: https://github.com/dart-lang/language/blob/main/accepted/future-releases/unquoted-imports/feature-specification.md Original design below (which also has some good parts, a final result might be something in-between). ----------------------------- This is a proposal for a shorter import syntax for Dart. It is defined as a shorthand syntax which expands to, and coexists with, the existing import syntax. It avoids unnecessary repetitions and uses short syntax for the most common imports. ## Motivation Dart package imports are fairly verbose because they are based on URIs with no shorthands. A fairly typical import would be: ```dart import "package:built_value/built_value.dart"; ``` The repetition alone is grating, and Dart imports can typically be split into three groups: * Platform libraries, `import "dart:async";`. * Third-party packages, `import "package:built_value/built_value.dart";`. * Same package relative import, `import "src/helper.dart";`. The package imports are the ones with most overhead. For the rest, the surrounding quotes and trailing `.dart` are still so ubiquitous that they might as well be assumed. ## Syntax The new syntax uses no quotes. Each shorthand library reference is provided as a *URI-like* character sequence containing no whitespace, and consisting only of identifiers/reserved words separated or prefixed by colons (`:`), dots (`.`) and slashes (`/`). The allowed formats are: * A single shorthand Dart package name. *

Posted by lrhn on Oct 29, 2019, 2:52 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

github (Software)

Import shorthand syntax

lrhnOct 29, 2019, 2:52 AM

Most recent version: https://github.com/dart-lang/language/blob/main/accepted/future-releases/unquoted-imports/feature-specification.md Original design below (which also has some good parts, a final result might be something in-between). ----------------------------- This is a proposal for a shorter import syntax for Dart. It is defined as a shorthand syntax which expands to, and coexists with, the existing import syntax. It avoids unnecessary repetitions and uses short syntax for the most common imports. ## Motivation Dart package imports are fairly verbose because they are based on URIs with no shorthands. A fairly typical import would be: ```dart import "package:built_value/built_value.dart"; ``` The repetition alone is grating, and Dart imports can typically be split into three groups: * Platform libraries, `import "dart:async";`. * Third-party packages, `import "package:built_value/built_value.dart";`. * Same package relative import, `import "src/helper.dart";`. The package imports are the ones with most overhead. For the rest, the surrounding quotes and trailing `.dart` are still so ubiquitous that they might as well be assumed. ## Syntax The new syntax uses no quotes. Each shorthand library reference is provided as a *URI-like* character sequence containing no whitespace, and consisting only of identifiers/reserved words separated or prefixed by colons (`:`), dots (`.`) and slashes (`/`). The allowed formats are: * A single shorthand Dart package name. *

Comments (0)

No comments yet. Start the discussion.

Comment on this issue