Open cgrand opened 1 year ago
Have it participate in core protocol? What do you have in mind?
@dupuchba I was thinking about having nth and maybe get and assoc to work on records but reading more about records abated my ambitions. Destructuring alone would be great.
Records:
$1
(a clojure symbol) for $1
the record accessor. However $1
only occur in interop member lookup so they won't undergo munging. However writing .-$1
to access a positional field is consistent with dart but a bit noisy. Could/should we shorten it to .-1
in ClojureDart?#dart (1 2 3 .name "z")
seems to be a reasonable syntax and reuse arguments parsing in the same way the Dart syntax reuse Dart arguments parsing.on
is a reserved word for us so we never emit a function or local named on
✅
3.2 metadata: we never emit space between a callable or its arguments so we should be safe ✅#/(...)
; we have #/(x y .z -> r)
(not sure about optionals) for functions, we have #/(List String)
for parametrized types. How do we add records to that? #/(Record x y .z)
? requires special casing the Record class, unlike what we have done for Function but otherwise it means finding a syntax... #/[x y .z]
with brackets for records :-/ If we go with #/(Record x y .z)
the risk would be that the Record class gets true type parameters. It seems unlikely. Going with Record
is explicit (good) but long (slightly bad) and we can still provide syntactic sugar later. Square brackets still have some allure. Another option could be #/($ x y .z)
😱 In truth we never went the last mile and don't have syntax for optionals in function types. Thus the work on records will serve for functions.Points 1 and 2 should be quick enough. Point 3 is free. The hard work is on inference, type representation and type notation. Notation can be post-poned.
Notation for functions and records types with optionals
#/(int String (List) -> bool) ; positional
#/(int String .children List -> bool) ; named
Use the same for records
#/[int String (List)] ; positional
#/[int String .children List] ; named
https://medium.com/dartlang/dart-3-alpha-f1458fb9d232
We need support to create records, and have it participate in core protocols.
#dart (...)
for syntax ? We don't need to support pattern matching. Class modifiers:We should ensure that we don't use any of the things removed https://github.com/dart-lang/sdk/issues/49529