Tensegritics / ClojureDart

Clojure dialect for Flutter and Dart
1.41k stars 90 forks source link

Make calling a constructor without `new` nor ending `.` canon #52

Closed cgrand closed 2 years ago

cgrand commented 2 years ago

In Dart, new has been deprecated and their notion of constructor is wide as they have:

So it's unclear when in ClojureDart . or new should be required and it adds little value (except potentially making some cljc works).

Thus I propose making officially new and ending . optional.

It's happens to already work but these codepaths should be checked to really work (especially w/ regards to type inference).

cgrand commented 2 years ago

(List) expands to (new List) here https://github.com/Tensegritics/ClojureDart/blob/a1d35f3a7d1ce397a1989862a88254bf7ffc54b5/clj/src/cljd/compiler.cljc#L1002

(List/empty :growable true) expands to (. $lib:dc/List empty :growable true) which is then gantlet by emit-dot which has correct support for constructors: https://github.com/Tensegritics/ClojureDart/blob/a1d35f3a7d1ce397a1989862a88254bf7ffc54b5/clj/src/cljd/compiler.cljc#L1452-L1453 https://github.com/Tensegritics/ClojureDart/blob/a1d35f3a7d1ce397a1989862a88254bf7ffc54b5/clj/src/cljd/compiler.cljc#L1470-L1472 https://github.com/Tensegritics/ClojureDart/blob/a1d35f3a7d1ce397a1989862a88254bf7ffc54b5/clj/src/cljd/compiler.cljc#L1478

So all paths are clear!