"an abuse of macros?" HAHAHA you are funny Laurent :-)
On Dec 13, 10:32 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote: > Unless I've missed something implicit in your post, why do present us (and > particularly ajay, who's trying to understand the language) what I would > consider an abuse of macro, where regular functions would do the job very > well ? > > 2009/12/13 mbrodersen <morten.broder...@gmail.com> > > > There is nothing "wrong" about objects in Clojure as long as the > > objects are immutable. > > > Some people tend to think that "functional" is anti-"object oriented". > > That is IMHO the wrong way to think. They complement each other. Why > > limit the tools in your toolbox? F# (for example) shows how it can be > > done elegantly. > > > Here is one (quick and dirty done in 5 min) way of using objects in > > Clojure that (again IMHO) is fully compatible with the "Clojure style" > > of programming because the objects (maps) are immutable: > > > (defmacro ? [object value] > > "Get an object value - same as object.value in OO but immutable" > > `(get ~object (keyword (str '~value)))) > > > (defmacro ! [object method & args] > > "Call an object method - same as object.foo(); in C# but immutable" > > `((get ~object (keyword (str '~method))) ~object ~...@args)) > > > (defmacro != [object name value] > > "Set an object value - same as object.value = foo; in OO but > > immutable" > > `(assoc ~object (keyword (str '~name)) ~value)) > > > (defmacro !fn [object name fn & args] > > "Execute a function on an object value and sets the object value to > > the result - roughly same as using mutable object but done in an > > immutable style" > > `(assoc ~object (keyword (str '~name)) (~fn (get ~object (keyword > > (str '~name))) ~...@args))) > > > -- > > 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<clojure%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > >http://groups.google.com/group/clojure?hl=en -- 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