Getting an unset variable

Trash (now anti BLANK!) has been established as the value of unset variables. As the example in that thread states:

>> trash-value
** Error: TRASH-VALUE variable is unset

>> append [a b] get/any 'trash-value
** Error: APPEND does not allow adding ~ antiforms to blocks

But when I try this, I get quite different results:

>> trash-value
** Script Error: trash-value word is attached to a context, but unassigned

>> append [a b] get/any 'trash-value
** Script Error: trash-value word is not bound to a context

In fact, even GET/ANY doesn’t seem to work… even when I make sure the binding is right:

>> get/any 'trash-value
** Script Error: trash-value word is not bound to a context

>> get/any $trash-value             
** Script Error: trash-value word is attached to a context, but unassigned

So, what’s happening here? And how do I get trash out of an unset variable?

You're hitting a modern issue of "attachment binding":

Caching Binding Lookup, and "Attachment Binding"

Today's attached variables aren't unset, they don't exist at all.

It's possible to not draw a distinction in the UI, and treat these as existing but unset... but I suspect that's not a good thing to do.

But really, attachment binding is kind of dodgy. Better ideas are welcome.

What’s wrong with that? To me it seems the most logical approach. If I mention a variable which has never been set, I’d expect it to behave as if it were unset.

Attachment binding is just something that had to be done in order to get the system to boot under new binding rules. I don't have a coherent theory for it.

As such, I can't offhand immediately name "here's a thing that fundamentally doesn't work about equating attachment-bound things with being unset".

I can tell you that at least for my sake in debugging things, I like to know the difference.

But more generally, I can tell you that attachment binding is dodgy. If you try to pretend attachment-bound things are real variables that are backed by a memory location, then you'll be lying when you answer various questions like BINDING OF (not a great question to ask these days, crashes on things).

1 Like