On May 28, 9:59 pm, "Sina K. Heshmati" <s...@khakbaz.com> wrote:
> Hi Krukow,
[snip]
> The only member data _I'm_ able find are the ones that are passed to the 
> default constructor, namely at the time that the abstraction is reified. What 
> if I'd have to give create a member field that is not necessarily known by 
> the caller or instantiator. That is, it's the abstraction itself that has to 
> create and maintain the value of that field.

You mean something like a private field in Java that is not supplied
as a constructor argument, but computed as a function of the other
fields, and which is not necessarily accessible from callers. If I
understand correctly what it is you want, I think you are moving away
from Clojure, trying to somehow encapsulate an "object". See RH's note
on encapsulation: "Encapsulation of information is folly. Fields are
public. Use protocols/interfaces to avoid dependencies" [1].

Again, I believe that you can use gen-class if you really need to do
this.


> One of the abstraction that I was hoping to implement in Clojure is a 
> Scheme-like pair in order to demonstrate various memory management 
> techniques. Once we do (cons a b), an abstract pair should be made that only 
> contains a pointer to its location in memory: (tag address). Here's the pair 
> implementation [2] in Scheme R5RS.
>

So you want a mutable pair (fst, snd) where fst and snd can be mutated
arbitrarily? This is definately not the Clojure way :) In Clojure,
you'd either use a pair of atoms or refs, giving you managed
mutability, or you'd simply write a functional pair.


[snip]
> Thank you very much, Krukow. It sure did help.
>
> Kind regards,
> SinDoc

Glad it did :)

-- 
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

Reply via email to