I'm wondering if "dart:" will still be needed once "package:" / pub
is fully implemented. Couldn't "package:html" be used instead of
"dart:html" for example, and pub (or any other package manager) could
just ignore package imports for which there is no local package
installed, assuming it corresponds to a builtin package, such as
"html".
One pain is that "package" is a bit longer than "dart".
Possibly when importing plain identifiers, i.e. no uri scheme such as
"http:" is provided, then treat it as a package identifier:
#import("html");
#import("http://github.com/foo/bar");
I forgot to mention the main reason that this could be useful which is
to mock out builtin libraries.
Also, realized that plain identifiers are already treated as relative
URIs, thus "package:" (or similar) is necessary after all.
Also, I don't think it is currently allowed to import a "package:" URI
without a "/foo.dart" suffix. Maybe:
#import('package:foo');
could be short for:
#import('package:foo/foo.dart');
On Fri, May 18, 2012 at 12:15 PM, Bob Nystrom <rnys...@google.com> wrote:Well, packages _can_ consist of multiple libraries, but a good portion
> Right now, the semantics for interpreting a "package:" are very simple,
> which is good. Every Dart implementation (the VM, the editor, Dartium, frog,
> dartc, and dart2js) has to implement it, so it's not easy to iterate on. I
> definitely don't like the "foo/foo" redundancy, but I haven't put time into
> trying to eliminate just yet. It is on my radar, though.
of the time they will only consist of one.
So the single library case probably deserves a more convenient form. A package is essentially a
"variable" library path, right ?
So maybe packages could appear in import statements, similarly to how variables appear in Dart code.
This import:
#import('package:foo/foo.dart');
could be shortened to:
#import(foo);
It could additionally be considered whether dropping parentheses from
the directive syntax would be an improvement:
#import foo;
import foo;
On Mon, May 21, 2012 at 11:11 AM, Bob Nystrom <rnys...@google.com> wrote:I would say the latter, since that would allow for arbitrarily nested
>> This import:
>>
>> #import('package:foo/foo.dart');
>>
>> could be shortened to:
>>
>> #import(foo);
>
> Given this, would #import(foo.bar) mean "package:foo/bar.dart" or
> "package:foo/bar/bar.dart"?
packages (e.g. foo.bar.baz).
It would also allow other support files
to co-exist in a library's directory, such as tests.dart, the pubspec,
etc. In this case, I might also prefer using a standard name for the
entry point source file, such as library.dart or main.dart.
> Given this, would #import(foo.bar) mean "package:foo/bar.dart" orI would say the latter, since that would allow for arbitrarily nested
> "package:foo/bar/bar.dart"?
packages (e.g. foo.bar.baz).Right, that's important. But requiring each library to be in its own directory is pretty cumbersome, especially if we move towards not using #source. In that model, every source file would be a library, and it would suck majorly to have a directory for each one.
On Mon, May 21, 2012 at 11:11 AM, Bob Nystrom <rnys...@google.com> wrote:I would say the latter, since that would allow for arbitrarily nested
>> This import:
>>
>> #import('package:foo/foo.dart');
>>
>> could be shortened to:
>>
>> #import(foo);
>
> Given this, would #import(foo.bar) mean "package:foo/bar.dart" or
> "package:foo/bar/bar.dart"?
packages (e.g. foo.bar.baz). It would also allow other support files
to co-exist in a library's directory, such as tests.dart, the pubspec,
etc. In this case, I might also prefer using a standard name for the
entry point source file, such as library.dart or main.dart.
On 21 May 2012 17:34, Sean Eagan <seane...@gmail.com> wrote:On Mon, May 21, 2012 at 11:11 AM, Bob Nystrom <rnys...@google.com> wrote:I would say the latter, since that would allow for arbitrarily nested
>> This import:
>>
>> #import('package:foo/foo.dart');
>>
>> could be shortened to:
>>
>> #import(foo);
>
> Given this, would #import(foo.bar) mean "package:foo/bar.dart" or
> "package:foo/bar/bar.dart"?
packages (e.g. foo.bar.baz). It would also allow other support files
to co-exist in a library's directory, such as tests.dart, the pubspec,
etc. In this case, I might also prefer using a standard name for the
entry point source file, such as library.dart or main.dart.So you arrange your source code as:foo/bar.dartfoo/bar/baz.dart
I was tempted to suggest, search for one and then the other; but any amount of complexity in the lookup rules will result in aggravation and annoyance, and some outright bugs.
But we'd want to encourage people to use package nesting to make their
code uniquely identifiable, so there will be a lot of "import
com.foocorp.bar.bar".
Just have a way of distinguishing the two cases in syntax:
import foo.bar -> "foo/bar/bar.dart"
import foo.bar:baz -> "foo/bar/baz.dart"
import dart:html -> "dart/html.dart"
Just have a way of distinguishing the two cases in syntax:
import foo.bar -> "foo/bar/bar.dart"
import foo.bar:baz -> "foo/bar/baz.dart"
import dart:html -> "dart/html.dart"We've already seen from the hackathons and other feedback that users are confused by having multiple "path separators" in import statements with ":" and "/" so I'd like to move away from that.