I think the suggestions thus far are not ideal. Both protocols and
multimethods provide a way to define a default case. The default case gives
you opportunity to adopt a delegation / component based design.
(defprotocol IFlightOrgan
(flight-organ [this]))
(defprotocol IFlight
(can-fly? [this]
The problem with the protocols approach is that it leads to an explosion in
the number of explicitly defined records. His example was only with labels,
but I can imagine he might have borders and any number of other decorations
on the widgets, in which case he would need something like
(defreco
Cedric's is the approach I would take. Like he said, use private functions
for the shared code.
On Wed, Feb 8, 2012 at 8:49 PM, Cedric Greevey wrote:
> Is there a reason not to just use protocols for your mixins?
>
> (defprotocol Labelled
> whatever)
>
> (defprotocol Textfield
> whatever-else
Is there a reason not to just use protocols for your mixins?
(defprotocol Labelled
whatever)
(defprotocol Textfield
whatever-else)
(defprotocol Datetimepicker
something)
(defrecord Label
Labelled
whatever ...)
(defrecord Textbox
Textfield
whatever-else ...)
(defrecord LabelledTe
Hm, I wrote a reply yesterday figuring it would show up today (seeing as I
accidentally double posted last time because it did not show up at once),
but that reply seems to be lost.
I see what you mean now, I think. Seeing as you will have to build your
hierarchies yourself you might try someth
Thanks,
This works, but there's a problem: the labeledtextfield is not a
textfield anymore, it's a label. Therefore it does not behave like a
textfield (which implements other protocols as well). I need multiple
inheritance, in one way or another. I've been trying to find a way to
implement with m
It sounds a little like the decorator pattern would do the trick for
you in this case - am I missing something? In case I am not, I have
given it a shot using records and protocols:
(defrecord TextField [text])
(defrecord DatetimePicker [datetimes])
(defrecord Label [text widget])
(defprotocol Re
It sounds like a use for the decorator pattern, or am I missing
something? In case I am not I have given it a shot using records and
protocols:
(defrecord TextField [text])
(defrecord DatetimePicker [datetimes])
(defrecord Label [text widget])
(defprotocol Renderable
(render [this]))
(extend-p
Hi,
I found some posts about this topic, but they did not clarify things
in my head well enough, so I have to start my own... :)
I'm basically craving for multiple inheritance or mixins, at least
with my current way of thinking. I haven't really gone deep enough
with multimethods or protocols, so