Combining the two approaches: (defn bounded-queue [size] (with-meta (clojure.lang.PersistentQueue/EMPTY) {:bounded-size size}))
then look for (get (meta q) :bounded-size) in the protocol. Nice ... Thanks! On Feb 17, 11:04 am, Alexandre Patry <patry...@iro.umontreal.ca> wrote: > On 11-02-17 10:33 AM, pba wrote:> Not quite, the queue size needs to be > passed in at instantiation time > > for example you may want to have a 10 or 100 element queue depending > > on the element type. What I'm looking for is to somehow decorate the > > queue (or some other object) with behavior constraints (a la C++ > > traits) when the object is created. > > > Thanks! > > You can define a record like : > > (defrecord BoundedQueue [queue size]) > > where queue is the decorated queue and then consider the size of the > queue in your protocole extension. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en