Open gaaclarke opened 5 days ago
We already have import 'dart:ui' as ui show Color;
. However, the IDE won't suggest imports from 'dart:ui' if we have a show clause. Or the IDE won't add imports to the show clause, I don't remember well. Which is very inconvenient, unless it works now.
Ah right, thanks. I'll update the example.
One problem is that the library URIs are not globally unique. Almost in practice, but it's not guranteed. They definitely doesn't account for the version of the package, and different versions can have different APIs.
The suggested syntax is a problem. The .dart
is just a convention, so import 'package:foo/foo.dart/Foo';
is already defined to mean import the file Foo
in directory /foo.dart/
of package:foo
. The syntax is already taken.
A more realistic syntax could be package:foo/foo.dart#Foo
, which identifies thie file package:foo/foo.dart
and the fragment of that file with name Foo
, which is exactly what a declaration named Foo
is.
It could be useful to have a global (semi-)unique way to identify a declaration.
The "libraryURI#name" is sufficient so far, but with agumentations, one migth want to denote the individual syntactic declarations that combine to a liibrary member. Might need fileUri#Name#number
for the numberth declaration named Name
in in the file identified by fileUri
.
It's non-trivial. Code is not static, it evolves over time, and references have to be either very high-level, or they should expect to become stale. Even high-level references can get stale accross major package versions.
The problem
The Dart language doesn't have a way to specify exactly what class one is talking about canonically. This is a minor nuisance when communicating between humans or to an LLM where one must say something like "an instance of Color from 'dart:ui'". However, a lack of consistency when communicating about Dart classes is also an impediment when building semantic understanding in an LLM.
Here is an example of something I've had to request to an LLM:
Proposal
I propose we make an additional form for
import
to codify a format for communicating about specific classes. I don't think the form has much value to users programmatically, but meta-language-wise it is valuable.These would behave similarly to:
After this is established I could request to the LLM: