Skip to content

Commit 451b944

Browse files
committed
Update alternative-generalized-feature-specification.dart
1 parent 8b15bb0 commit 451b944

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

working/tagged-strings/alternative-generalized-feature-specification.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,19 @@ By allowing many non-literal primary expression as the “tag”, a some mistake
182182
183183
On the other hand, we could probably allow `<primary> <selector+> <stringLiteral>`, making a string literal a *selector*
184184
185-
It can probably safely be restricted to not allow literals or function expressions. Those are incapable of implementing `StringInterpolation` anyway.
185+
It can probably safely be restricted to not allow literals or function expressions. Those are incapable of implementing `StringInterpolation` anyway.
186+
187+
### Similarity to “tagged collections”
188+
189+
If Dart introduces a way to generalize collection literals, then the syntax *could* be something like;
190+
191+
```dart
192+
var c1 = MyCollection<int>(capacity: 24){1, for (var i = 2; i <= 23; i+= 3) i, 26};
193+
// or
194+
var c2 = myCollectionTag{1, 2, ...more};
195+
```
196+
197+
That would be similar to the the format for tagged string interpolations containing elements. (And without tagged collections, one could do `var c3 = myCollection"${1, 2, …more}";` and get away with it. Which suggests that maybe the two features should be developed together.)
186198
187199
## Versions
188200

0 commit comments

Comments
 (0)