Dart conditionally imported library
This is a proposal for a new guarded import syntax which allows conditionally either importing or *not* importing a library, and telling at runtime which one it was. The allowed conditions are the same as for the current conditional imports. The import works like a deferred library which is either always loaded or never loaded. We add guards to check whether the library is loaded or not. ## Specification ### Import syntax and semantics The import syntax of conditional imports is changed so you can omit the *first* URI string. In that case, it must be followed by precisely one `if (….) URI` condition, and it must then be followed by a prefix name clause `as name` . It cannot be `deferred`. ```ebnf <importSpecification> ::= `import' <configurableUri> (`deferred' `as' <identifier>)? <combinator>* `;' <configurableUri> ::= <uri> <configurationUri>* ``` becomes ```ebnf <importSpecification> ::= `import' <configurableUri> (`deferred' `as' <identifier>)? <combinator>* `;' | `import' <configurationUri> `as' <identifier> <combinator>* `;' <configurableUri> ::= <uri> <configurationUri>* ``` Example: ```dart import if (dart.library.io) "some_io_library.dart" as some; ``` The prefix name can only be shared with other conditionally imported libraries with the *same* condition. _Alternatively we can allow `<configurationUri>+` in the conditional import, to allow at most one of multiple libraries to be loaded, depending on configuration, but still allow ending up wi
Posted by lrhn on May 12, 2022, 2:48 PM
Tags
Related issues
- [Meta] Feedback on granular control over Copilot changes
- unexpected status 401 Unauthorized issue
- [MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
- [CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
- Video stops playing after some minutes
- [MODEL] Claude verbose code comments by default — ignores instructions to stop.
Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments
github (Software)
[Meta] Feedback on granular control over Copilot changes
unexpected status 401 Unauthorized issue
[MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
[CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
Video stops playing after some minutes
[MODEL] Claude verbose code comments by default — ignores instructions to stop.
Scope Codex VS Code chats to the current workspace/project
Update on "Co-authored-by: Copilot" in commit messages
Dart conditionally imported library
This is a proposal for a new guarded import syntax which allows conditionally either importing or *not* importing a library, and telling at runtime which one it was. The allowed conditions are the same as for the current conditional imports. The import works like a deferred library which is either always loaded or never loaded. We add guards to check whether the library is loaded or not. ## Specification ### Import syntax and semantics The import syntax of conditional imports is changed so you can omit the *first* URI string. In that case, it must be followed by precisely one `if (….) URI` condition, and it must then be followed by a prefix name clause `as name` . It cannot be `deferred`. ```ebnf <importSpecification> ::= `import' <configurableUri> (`deferred' `as' <identifier>)? <combinator>* `;' <configurableUri> ::= <uri> <configurationUri>* ``` becomes ```ebnf <importSpecification> ::= `import' <configurableUri> (`deferred' `as' <identifier>)? <combinator>* `;' | `import' <configurationUri> `as' <identifier> <combinator>* `;' <configurableUri> ::= <uri> <configurationUri>* ``` Example: ```dart import if (dart.library.io) "some_io_library.dart" as some; ``` The prefix name can only be shared with other conditionally imported libraries with the *same* condition. _Alternatively we can allow `<configurationUri>+` in the conditional import, to allow at most one of multiple libraries to be loaded, depending on configuration, but still allow ending up wi
Comments (0)
No comments yet. Start the discussion.