On Fri, Dec 27, 2013 at 2:32 PM, Mark Engelberg <[email protected]>wrote:

> On Fri, Dec 27, 2013 at 10:27 AM, Cedric Greevey <[email protected]>wrote:
>
>> On Fri, Dec 27, 2013 at 1:08 PM, Mark Engelberg <[email protected]
>> > wrote:
>>>
>>>  Solution 2:
>>>
>>> (defn foo [shared-info x] ... body uses shared-info)
>>> (defn bar [shared-info x] ... body uses shared-info)
>>>
>>> Call these functions via:
>>>
>>> (foo info 2)
>>> (bar info 3)
>>>
>>
>> In what way is this any worse than
>>
>> info.foo(2);
>> info.bar(3);
>>
>
> In an OO implementation, the definitions of foo and bar could be
> dramatically more concise because from within the object, references to the
> other components of the object don't need to be prefixed with "info."  This
> is a big deal.
>

Erm,

(defn foo [{:keys [thingy mumble fiddly]} x]
  (...thingy ... mumble ... fiddly ... mumble ... mumble ... x ... thingy
...))

After from one brief incantation in the parameter list you can just go
ahead and refer to the "fields" like in an OO method body.


There's also protocol + defrecord and record fields referenced in the
function bodies in the defrecord.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to