On Fri, Dec 27, 2013 at 10:27 AM, Cedric Greevey <cgree...@gmail.com> wrote:

> On Fri, Dec 27, 2013 at 1:08 PM, Mark Engelberg 
> <mark.engelb...@gmail.com>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.

In Clojure, the closest comparison is namespaces, which let you use other
names from within the same namespace without explicit prefixing.  But in
Clojure there's no way to combine a namespace's capability for things
referring to one another without a prefix with a problem where some of that
data can be initialized/configured to different initial values.

Contrast that with classes-as-namespaces and you see that there is a
mechanism both for things in a class to refer to one another without
prefixes, and to easily turn it into something where a constructor sets up
some initial values.

-- 
-- 
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
--- 
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to