[plt-scheme] string properties

From: Neil W. Van Dyke (neil at neilvandyke.org)
Date: Sun Jun 20 16:38:38 EDT 2004

I'd like to secretly associate data with normal string values.

The interface could be like this:

    (set-string-property! STR VALUE)  -->  #<void>
    (string-property      STR)        -->  VALUE

Or like this:

    (make-string-property NAME)                -->  STR-PROP
    (set-string-property! STR STR-PROP VALUE)  -->  #<void>
    (string-property      STR STR-PROP)        -->  VALUE

For my current application, it would be OK if the property value applied
to all strings "equal?" rather than "eq?".

I'm thinking a PLT hash table with weakly-held keys, mapping strings to
values, would work for this purpose.

Is there a better way?

Posted on the users mailing list.