Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cgrand opened this issue May 3, 2022 · 1 comment
Closed

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

cgrand opened this issue May 3, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@cgrand
Copy link
Contributor

cgrand commented May 3, 2022

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

  • default constructor
  • named constructors (to palliate the lack of overloads)
  • const (interning) constructors
  • factory constructors -- which are not even constructors any more IMO

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 cgrand added the enhancement New feature or request label May 3, 2022
@cgrand
Copy link
Contributor Author

cgrand commented May 3, 2022

(List) expands to (new List) here

:class (fn [form _ & _] (with-meta (cons 'new form) (meta form)))

(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:

_ (when (and static (not (or (:static member-info) (= :constructor (:kind member-info)))))
(throw (Exception. (str member-name " is neither a constructor nor a static member of " (:element-name type!)))))

prop (case (:kind member-info)
:field true
(nil :method :constructor) prop)

(not prop) (:return-type member-info)

So all paths are clear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant