Tensegritics / ClojureDart

Clojure dialect for Flutter and Dart
1.38k stars 88 forks source link

Make magicast open #290

Open cgrand opened 8 months ago

cgrand commented 8 months ago

Magicasting is the process of generating adapter code when passing an argument whose runtime type is unknown is incompatible with the statically expected type.

This is how for example a Clojure vector is dynamically typed AND can still be passed to any Dart method expecting a List<Foo>.

Adapter code is expected to run in constant time -- if something can't be adapted cheaply it shouldn't be implicitely adapted.

This issue is there to collect thoughts about allowing user to extend magicasting (a bit like one can extend core protocols). Similar precautions to protocol extension should be taken: avoid creating an extension when you don't own one of the type/protocols involved.

An extension that cljd.core could provide could be allowing function to be magicasted to Sink for example.

Generally is more magicasting a good idea (or too magic like the example above) ? If it's a good idea, should we open it or is it a Pandora's box?