Skip to content

Improve on library imports #71

@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


In the specs it reads

libraryImport:
'#' 'import' '(' stringLiteral (', ' 'pre fix:' stringLiteral)? ') ';'
;

This is utterly redundant.

I would like to suggest that this will be reduced to either

libraryImport:
'#' 'import' stringLiteral 'as' stringLiteral;
;

or, by making this more 'compatible' to CommonJS

libraryImport:
stringLiteral = 'import' stringLiteral;
;

The extra opening and closing brackets are not really necessary unless

import was a function, which it definitely is not.

And if it were, then the '#' hash before the 'import' keyword should be removed, leaving us with

libraryImport:
stringLiteral = 'import' '(' stringLiteral ')';
;

Having this, one could also just import specific elements declared by the library, such as

foo = import('bar').foo;

or, using the import...as notation

libraryImport:
'import' '(' stringLiteral ')' ('as' stringLiteral)?;
;

However, using stringLiteral for the prefix is rather weak, as it definitely needs to be an identifier.

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions