archives

« Bugzilla Issues Index

#2287 — Simplify ImportClause


http://people.mozilla.org/~jorendorff/es6-draft.html#sec-imports

Currently says

ImportClause :
ImportedBinding
ImportedBinding , NamedImports
NamedImports

I don't think it is worth allowing both default and named imports in the same ImportClause. The following simplification seems to be simpler to reason about.

ImportClause :
ImportedBinding
NamedImports

If we are going to allow both we need to support different ordering too.

ImportClause :
ImportedBinding
ImportedBinding , NamedImports
NamedImports
NamedImports , ImportedBinding


Dave, after talking through the issues I'm convinced that what we want is:

ImportClause :
ImportedBinding
ImportedBinding , NamedImports
NamedImports
NamedImports , ImportedBinding

Can you confirm?


What is the status on this issue?

My instinct agrees with Erik here. Allowing a mixture of default import and named imports in the same production is messy, and we don't have any evidence that such mess is necessary. An optimization like this can always be added in a future version if experience warrants it.


The ability to do both in one line is necessary. Keeping the order fixed is clearer, will lead to a simpler grammar and a more consistent programming style, and there's far more precedent for comma-separated sequences being ordered (sequence expressions, function arguments, etc).

Dave


Strictly speaking you already can "do both in one line" with just NamedImports:

import { a, b, c, default as x } from "somewhere";

To my eyes, this is much nicer than:

import x, { a, b, c} from "somewhere";

which really just obfuscates the whole design. It smells bad.

My opinion, take it for what it's worth.