[plt-scheme] Tagging primitive types?

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Thu Dec 1 11:59:05 EST 2005

On 12/1/05, Erich Rast <erich at snafu.de> wrote:
>
> > Erich, are you trying to associate the tags with values, variables, or
> > expressions?  If you want to associate a tag with values (in the
> > equivalence class generated by eq?) you could use a hash-table stored
> > in a parameter or global variable for this.  (If not, I'm unclear on
> > what behavior you really want.)
>
> I'm not sure if I understand your answer. Perhaps I didn't express
> myself clear enough---and unfortunately my example was wrong, because I
> used define to set both values, which of course wouldn't work without
> redefining define.
>
> I'm looking for a hack to make an identifier have *two* values. The
> ordinary value is just a normal binding. The second value can be get
> and set only by special functions or macros.

I don't understand why you need this.  This is such a special-case
solution - limited in both power and scope - and you can solve it so
easily by doing

(define a VALUE)
(define a-tags TAGS)

that I don't understand why you need to build this "automatic
association".  Why would you ever need to run tagged?, for instance,
or untag, if what's being tagged is a locally scoped variable?  If you
want to know if it's tagged - just look up in the code and see if the
*-tags variable exists.  If you want to "untag" it - just stop
referring to *-tags and let it be garbage collected.

So it might be that your problem doesn't need much of a solution.  If
you still think it does, perhaps you can clarify what you're trying to
accomplish with this.  I can't think of any examples where I'd use
this.

--Carl


Posted on the users mailing list.