Could SIGIL! Carry A Binding?

So I'm rigging it up that COMPOSE2 works with SIGIL!:

>> var: 'x

>> compose2 '$ [x + $var]
== [x + y]

I'm assuming that since no lists are in the pattern, it would leave lists alone:

>> compose2 '$ [x + $var $(1 + 2)]
== [x + y $(1 + 2)]

Otherwise you'd get some kind of meaningless mixing and matching:

>> compose2 '@ '[[some stuff] @[spread [a b]] (other stuff) @(reverse [c d])]
== [[some stuff] a b (other stuff) [d c]]

But What If You Want To Use The Pattern's Context?

The above works great when you want to use the binding of the template block. But how would you say you wanted to use the binding of the calling environment?

So let's say the block is quoted, and unbound. This isn't legal today:

>> var: 'x

>> compose2 @$ '[x + $var]
== [x + y]   ; idea is to work even though we passed an unbound block

There's no THE-SIGIL! and no binding on sigils, so it won't work. BUT I WANT IT! :pouting_cat:

Could SIGIL!s Carry a Context, like an ANY-LIST Can?

Basically this means getting THE-SIGIL!, VAR-SIGIL!, META-SIGIL!, etc.

>> $$
== $  ; bound

>> @@
== @@  ; bound

This would make SIGIL! more similar to WORD!. But there's a catch... today's WORD! doesn't retain the environment it's bound to the way lists do, it binds specifically to the thing it looks up at the moment of binding. Hence if you bind in an environment where a variable isn't defined the word remains unbound even if the symbol becomes defined later in that environment.

So to be useful here, the SIGIL! would have to be like a BLOCK! or other list, and retain the entire environment. Hence not like today's words.

Maybe just being a magical outlier is all right. It is called "SIGIL" after all:

A sigil (/ˈsɪdʒɪl/) is a type of symbol used in magic. The term usually refers to a pictorial signature of a deity or spirit (such as an angel or demon. In modern usage, especially in the context of chaos magic, a sigil refers to a symbolic representation of the practitioner's desired outcome.

4 posts were split to a new topic: Worrying Over the Arity Of Compose

Yep, this looks good!

(Not sure how happy I am with bindings on sigils, though. That feels like it may open up the same can of worms as bindings on strings do.)

It wouldn't be the case that sigils would get bound too often, since they have evaluator behavior which is not driven by binding.

>> @ x
== x  ; bound

>> $ first [x]
== x  ; bound

In neither case did the @ or the $ become bound.

This is actually the big question, because I'm starting to think that words should retain the whole binding environment the way lists do. In which case it would be no particular problem to let SIGIL! do that too.

That has some unfortunate-seeming implications for performance--that words don't have a way to memorize the exact thing they look up to, to quickly fetch that same value every time.

But living in a mostly-unbound world, that's kind of already the case. I think it is probably a change that has to be made.

I'll point out that this would mean killing the SIGIL! for quoted and quasiforms, as @' and $~~ are clearly illegal-looking things.

This is probably for the best. Those sigils don't make sense.

>> quotes of first [']
== 0

>> sigil of first [~abc~]
== ~~

Only non-quoted, non-quasi (and non-antiform types) should respond to SIGIL OF.

However, this means these patterns may be repurposed...!