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

Polymorphism ideas #41

Closed
chrisosaurus opened this issue Jul 9, 2016 · 3 comments
Closed

Polymorphism ideas #41

chrisosaurus opened this issue Jul 9, 2016 · 3 comments

Comments

@chrisosaurus
Copy link
Contributor

As of #37 we now have contains?, array-contains?, string-contains?.

I see a few ways of handling this:

  1. don't, many lisps never handle this, so leave it be.
  2. have the contains? method test it's argument and dispatch to list-contains?, array-contains?, string-contains? - this works for builtin types but cannot be user extended.
  3. have contains operate via an interface that supports all the builtin types that can also be extended - I am unsure if Carp currently has the capability for this.

What are your thoughts?

@chrisosaurus
Copy link
Contributor Author

hmm on second-thought maybe option (2) is actually user-extendible if functions/macros are powerful enough

maybe (contains? foo) could dispatch to (typeof(foo)-contains? foo)

this would require something being able to get a typeof string, append "-contains?" (or arbitrary function names) and then call it (via eval I presume?)

@eriksvedang
Copy link
Collaborator

Yes, this is very interesting. My hope is to implement something like this eventually, and your solution is nice and simple. The first 0.1 release of carp won't have it though, I want to sort out some bigger things (like modules) first!

@porky11
Copy link

porky11 commented Oct 7, 2017

the reason why other lisps don't handle it, is that they are dynamically typed.
another low level lisp already handles this: dale

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

No branches or pull requests

3 participants