Closed solson closed 9 years ago
Related: what is the state of multimethods in Apricot? Could dispatch-on-arity be a thing?
Sorry, just getting my feet wet and coming from a background of MRI + JVM Clojure :smile:
There's currently no support for Clojure-style multimethods. What exactly do you mean by dispatch-on-arity (as opposed to the already implemented arity-overloaded fns)?
Using multimethods to emulate Java overloading based on args/arg arity... I
don't even like using multimethods that way in Clojure (usually just
dispatch on a fn like class
), just curious about the state of
multimethods in Apricot. Thanks.
Jason Lewis
vox 410.428.0253 twitter @canweriotnow blog http://decomplecting.org else http://about.me/jason.lewis
On Wed, Dec 4, 2013 at 8:42 PM, Scott Olson notifications@github.comwrote:
There's currently no support for Clojure-style multimethods. What exactly do you mean by dispatch-on-arity?
— Reply to this email directly or view it on GitHubhttps://github.com/apricot-lang/apricot/issues/38#issuecomment-29864628 .
I'm closing this since Apricot is effectively abandoned, but I'm open to pull requests if anyone is interested.
Take the function
map
for example:Here's the top bit of its decoded assembly:
The point is that Rubinius allows users to pass only 2 or 3 arguments to
map
, so if thatpassed_arg 2
check (checking for the 3rd argument) fails, we know for sure 2 arguments were passed and we don't need to check withpassed_arg 1
. This current code works but does pointless extra work.I'm sure there are other cases like this I haven't considered.