[Openmcl-devel] User contributions
ron at awun.net
Wed Jun 17 12:42:30 PDT 2009
On Jun 17, 2009, at 11:57 AM, Dan Weinreb wrote:
> Ron Garret wrote:
>> It should not be this hard to make a guardian. In fact, at this
>> point I still don't know a way to do it that actually works in a
>> compiled file in CCL.
> What's a guardian?
It's a singleton object that is used for its value alone, not for any
operations that it performs.
> That is, what are you actually trying to do here?
I'm trying to implement abstract iterators without using conditions.
> It looks like you are trying to establish an object
> that you know will be distinct from any object
> that is produced by any future call to read,
> and you want to give it a global name, and
> you want to make sure that a compile-time
> error will happen if there is any attempt
> to set or bind that name. Is that the goal?
Almost. Having the guardian bound to a global name is a convenience,
not a requirement. I don't really care if I access the guardian by
typing +guardian+ or (+guardian+) or even (funcall '#.#'+guardian+) if
push comes to shove.
The invariant that I want to maintain is that the result of any
reference to +guardian+ (or (+guardian+) or whatever) is always EQ to
any other such reference or call, and always NOT eq to the result of
any computation that does not reference or call +guardian+. And this
invariant must hold regardless of any intervening operations (i.e.
file compilations and load, assignments, etc.)
It doesn't matter whether operations that would cause the invariant to
be broken result in an error (like trying to rebind a constant), or if
such operations are merely impossible (like trying to reassign a
closed-over value in the absence of an explicit provision for do such
BTW, just for perspective, this makes a very interesting intellectual
exercise, but it's not all that important for my purposes. I'm
content to work around the problem by simply using an interned symbol
with a very obscure name. But I do think there's an argument to be
made that allowing:
(defconstant foo ...)
(defun foo () foo)
(eq foo (foo))
to return NIL is a bug in the spec.
More information about the Openmcl-devel