How can I force dispatch to an existing multimethod implementation?

If I declare a multimethod for another namespace (a library which I cannot change), ns-a, for my type: defmethod ns-a/method-a Y [y] and there's an existing method for X defined in...

pretty-printing a record using a custom method in Clojure

In Clojure 1.5.0, how can I provide a custom pretty-printer for my own record type, defined with defrecord. (defrecord MyRecord [a b]) (defmethod print-method MyRecord [x ^java.io.Writer writer] ...

Clojure: defmulti on different class types

Quick clojure question, I think this is mostly syntax related. How do I dispatch a multimethod based on specific type signatures of the arguments, for example: (defn foo ([String a String...

C++ multimethods and compile time detection

I have the following code : class A{}; class B: public A{}; class C: public A{}; class MyVisitor { public: void visit(B*); void visit(C*); }; And then collection of A* objects,...

Performance of multimethod vs cond in Clojure

Multimethods are slower than protocols and one should try to use protocols when they can solve the problem, even though using multimethods gives a more flexible solution. So what is the case with...

Why Elixir doesn't use Multimethods / Protocols?

Let's see the example from docs: square = fn(x) -> x * x end list = [1, 2, 3, 4] Enum.map(list, square) Why does it requires to explicitly write Enum.map? Why it doesn't use clean and short...

Colliding stellar objects via multimethods in OO Prolog?

I wonder how one would combine unification and OO in Prolog. I would like to implement a multimethod dispatch on term objects. Without term objects and simple terms I would do the following and...

Nim - Create sequence of objects which implement a method

I want to program a game and would like to use a component pattern for multiple entities. In a language with interfaces / type-classes / multiple inheritance there would be no problem. I want some...

Are functions mutable in multiple dispatch systems?

Have I understood correctly that in (most? some?) multiple dispatch languages each method gets added to the function at some point in time of program's execution. Can I then conclude that multiple...

Anylogic: Queue decision making of Agents

I am working on a model for my thesis about attraction visiting decision-making of tourists in Anylogic. How can I give the visitors (agents) varying maximum waiting times. So that if a queue of...

How to reload a multimethod in Clojure REPL

I am writing a multimethod in the REPL, functions can be redefined just fine, but if I redefine the dispatch function of a multi method it seems not to use the newly refined function: ;; simple fn...

How does a Perl 6 object find a multi method that might be in a parent class or role?

Consider this example where a subclass has a multi method with no signature and one with a slurpy parameter: class Foo { multi method do-it { put "Default" } multi method do-it ( Int $n ) { put...

Why does a Perl 6 Str do the Positional role, and how can I change []?

I'm playing around with a positional interface for strings. I'm aware of How can I slice a string like Python does in Perl 6?, but I was curious if I could make this thing work just for giggles. I...

What does retag parameter in s/multi-spec mean?

Can you explain with examples how does retag parameter impacts multi-spec creation? I find multi-spec documentation hard to digest.

Multimethod dispatch on namespaced map namespace

Is it possible to dispatch based on a namespaced map namespace i.e. #:<this-thing>{}? Without hacks like printing or inspecting key prefixes? I consider the last one hacky because a key prefix can...

How to call default multimethod from within multimethod

Suppose I have a multimethod: (defmethod print-method MyObject [obj writer] (.write writer (format "%s %s" "prefix" ...

How does (constantly x) differ from (fn [& _] x)?

I'm using a multimethod to provide different functions depending on what "mode" my project is running in (it's a yada api server, and should be able to run in :dev, :prod modes etc). I'm using...

Modifying parameters as part of a multimethod

What's the idiomatic way to write a multimethod that modifies the incoming arguments as part of it's dispatch? In this case, I want to drop one of the arguments: (defmulti do-update...

JSON representation problem with liberator

I'm trying to define a really simple resource with Liberator. To start off a minimal example, I wrote an handler like this: (resource :handle-ok {:hello "world"}) But despite clearly passing a...

Clojure Domain Modeling: Spec vs. Protocols

This question became really long; I welcome comments suggesting better forums for this question. I am modelling the swarming behavior of birds. To help me organize my thoughts, I created three...

Dispatching function calls on different formats of maps

I'm writing an agar.io clone. I've lately seen a lot of suggestions to limit use of records (like here), so I'm trying to do the whole project only using basic maps.* I ended up creating...

Perl 6 multi methods never match expected signature

I have a class with two multi methods (multi submit). I call my multi like this: $perspective.submit(:message($message.content)); Which gets shipped off to my class: my $perspective-api =...

Why can't anything go in the body of a Perl 6 grammar proto?

When declaring a proto, it's possible to surround the multimethod/sub code with additional code. For a silly example: proto sub foo(|) { 'Camelia says “' ~ {*} ~ '!”' } multi sub foo(1) {...

How do I load data structures containing atoms stored in a file in clojure?

I have a file containing a map containing maps. I simply used spit to save the map to a file.The data looks like this(its a bit long): {:10 #nelson_clojure.brain.skeleton{:state...

What are the benefits of using multimethods instead of cond in Clojure?

Why shouldn't multimethods in Clojure simply be replaced by cond expressions? I was inspired to ask after looking at the simple examples of multimethods in Ch. 5 of Russ Olsen's book Getting...

How "vars" in Jenkins Shared Libraries work?

I'm experiencing some behaviors in Jenkins Shared Libraries, and it'll be great if someone can explain this to me: First issue Let's say i have a file in the vars directory: //...

Haskell-like pattern matching in Raku

Haskell and Rust (and mabye other languages of which I am not aware) have a fature which they call "pattern matching". Here is an example in Haskell: data Event = HoldKey Char | PressKey Char |...

Is there any difference between multimethod and multipledispatch?

I would like to use overloading in Python. I know it's not possible by design (Python is dynamically typed language), there is quite good thread here on this topic. That's why I could use...

Why is it not common to use functional design patterns in dynamic typed languages?

At first let's make things clear. By functional design patterns I mean patterns/types/classes like functors, monads, monoids, semigroups etc. that are common in static typed languages and by...

How to install PyCaret in AWS Glue

How can I properly install PyCaret in AWS Glue? Methods I tried: --additional-python-modules and --python-modules-installer-option Python library path easy_install as described in...