I tend to add the metadata in manually when I write multimethods.
(defmulti foo
"Does some foo to x."
{:arglists '([x])}
:type)
- James
On 23 August 2015 at 16:51, Dave Tenny wrote:
> defmulti+detmethod doesn't seem to maintain any :arglists metadata with
> the Var filled by defmulti.
>
defmulti+detmethod doesn't seem to maintain any :arglists metadata with the
Var filled by defmulti.
How can I look up arglist information for multimethods like I can for
regular function vars?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To p
I see where you are going. You don't actually need to store the system
in an atom as it can be directly referenced from reloaded.repl.system,
but I get your point (i.e. adapters).
Thanks Marc.
On 25 February 2015 at 14:26, Marc Limotte wrote:
> Hi Colin,
>
> Nesting defmethod in t
Hi Colin,
Nesting defmethod in the start fn of the Component does have a bad smell.
This actually seems counter to the intention of Component, which is to make
these dependencies explicit and external. I might do it like this:
1. Create a "pure" implementation using Component as it wa
gt; wrote:
>> > So I guess another question is where "handle-command" is being called.
>> > What
>> > about providing the component as argument to the multimethod (there are
>> > other approaches too depending on your need). So:
>> >
>>
gt; So I guess another question is where "handle-command" is being called.
> What
> > about providing the component as argument to the multimethod (there are
> > other approaches too depending on your need). So:
> >
> > (defmulti handle-command(fn
ending on your need). So:
>
> (defmulti handle-command(fn [component command] (first command)))
>
> (defmethod handle-command :add-customer [{:keys [db eventstore} [[_
> customer]]]
> ... )
>
> Isn't something like this enough?
>
> Jeroen
>
> On Wed, Feb
So I guess another question is where "handle-command" is being called. What
about providing the component as argument to the multimethod (there are
other approaches too depending on your need). So:
(defmulti handle-command(fn [component command] (first command)))
(defmethod handle-co
and so on.
One way of achieving this is (assuming commands are of the form
[:command-discriminator payload]:
(defmulti handle-command first)
(defn add-customer [db eventstore customer]
...)
(defrecord AddCustomerComponent [db eventstore]
...
(start [this] (defmethod handle-comman
ed, Feb 25, 2015 at 12:08 PM, Colin Yates wrote:
> Hi,
>
> I have a number of commands flying around which need to be handled.
> defmulti/defmethod seem a nice answer. The problem is that each command
> handler will need different collaborators (those with long memories will
> r
Hi,
I have a number of commands flying around which need to be handled.
defmulti/defmethod seem a nice answer. The problem is that each command
handler will need different collaborators (those with long memories will
realise this isn't new ground here ;)).
I want to do something like:
This is an unfortunate ugly side effect of def and def-like forms being,
um, side effectual.
In the particular case of defmethod, I think that the general
recommendation would be to structure your namespaces such that methods are
defined along side the code that could produce dispatch values
2013 at 5:19 PM, Steven Degutis
> > wrote:
>
>> In my app, sometimes a file containing a defmethod hasn't been
>> required yet by the time some other function calls the multi-method.
>> So naturally it throws an exception.
>>
>> But later, as the app con
13 at 5:19 PM, Steven Degutis wrote:
> In my app, sometimes a file containing a defmethod hasn't been
> required yet by the time some other function calls the multi-method.
> So naturally it throws an exception.
>
> But later, as the app continues to run, the file containing the
In my app, sometimes a file containing a defmethod hasn't been
required yet by the time some other function calls the multi-method.
So naturally it throws an exception.
But later, as the app continues to run, the file containing the proper
defmethod eventually gets required by another file.
Hi,
Am 19.12.2010 um 19:35 schrieb Robert McIntyre:
> @Ken Wesson: do you mean something like this:
> https://gist.github.com/747571
Maybe I'm missing something, but why don't you just call the multimethod itself
again in the trampoline fn?
Sincerely
Meikel
--
You received this message becau
@Ken Wesson: do you mean something like this:
https://gist.github.com/747571
My fists stab at this technique looks kinda ugly though...
Is there a way to somehow embed the trampoline inside the recursive definition?
Is there a way to get the actual dispatch function other than
(.dispatchFn multime
Hi,
Am 19.12.2010 um 16:46 schrieb Ken Wesson:
> If we had a (resolve-method multi & args) that resolved dispatch and
> then returned a fn that would call the method with those same args --
> so ((resolve-method multi & args)) <=> (multi & args) -- then this
> could be used with trampoline in cas
On Sun, Dec 19, 2010 at 10:34 AM, Sunil S Nandihalli
wrote:
> thanks Meikel for your clarification.. I used to think loop recur almost
> removed the need for TCO .. but here is a case where true TCO could be
> really helpfull..
If we had a (resolve-method multi & args) that resolved dispatch and
andihalli:
>
> > Hello everybody,
> > It would be nice if calling recur inside a defmethod redispatched on the
> new arguments.. I have shown a simple use-case in the following gist.
> > https://gist.github.com/747171
> >
> > It might be naive .. but I feel IMHO that t
Hi,
Am 19.12.2010 um 08:30 schrieb Sunil S Nandihalli:
> Hello everybody,
> It would be nice if calling recur inside a defmethod redispatched on the new
> arguments.. I have shown a simple use-case in the following gist.
> https://gist.github.com/747171
>
> It might be n
Hello everybody,
It would be nice if calling recur inside a defmethod redispatched on the
new arguments.. I have shown a simple use-case in the following gist.
https://gist.github.com/747171
It might be naive .. but I feel IMHO that this should be the default
behaviour and not have any
tch function should match your methods in arity. It may take
> more if they are "don't cares" for the dispatch.
>
> > (defmulti projection (fn [shape & _] (type shape)))
> > (println 2)
>
> As I said, some cleanup with let (hopefully without messing things
(fn [shape & _] (type shape)))
> > (println 2)
>
> As I said, some cleanup with let (hopefully without messing things
> up). Also you cannot "call" integers with vectors. You have to use
> nth.
>
>
>
> > (defmethod projection :polygon
>
me cleanup with let (hopefully without messing things
up). Also you cannot "call" integers with vectors. You have to use
nth.
> (defmethod projection :polygon
> [shape plane]
> (let [points (:points shape)
> npoints (int (count points))
>
I'm not sure what to do here, my program hangs at the following
defmethod. all my brackets seem to be balanced and I'm not receiving
any errors about undefined symbols. This sample prints 2 but never
gets to 3, (my poor man's debugging). This code is for the collision
detecti
struct bar :c :d :e)
(defn struct-dispatch
([{_ :a _ :b _ :c}] ::foo)
([{_ :c _ :d _ :e}] ::bar))
(defmulti struct-method struct-dispatch)
(defmethod struct-method ::foo
; work on struct foo
)
(defmethod struct-method ::bar
; work on struct bar
)
Other supported destructurings wou
> That doesn't seem to be possible - I can't find a function that
> accepts a PersistentStructMap and returns the symbol passed to struct
> so it knows the keylist to use for the arguments. Nor could I find the
> magic incantation to let me use those symbol names with derive, which
> would let me u
seem to follow POLA. I
want to have a multimethod dispatch on structure types. Specifically,
if I define two structures:
(defstruct A :a :b :c)
(defstruct B :b :d :e)
I want a multimethod that uses different methods for A & B. I'd *like*
to be able to write them like:
(defmethod meth
eness:
(defmacro defmethod
"Creates and installs a new method of multimethod associated with
dispatch-value. "
[multifn dispatch-val & fn-tail]
`(. ~multifn addMethod ~dispatch-val
(fn ~(symbol (str multifn "-" dispatch-val)) ~...@fn-tail)))
; just added ~(symbol (str mul
30 matches
Mail list logo