try to stick with befunge specs regarding fingerprints semantics
commitbfccd58e19ff7e90eb5659cf49ba292496d47aee
authorJérôme Quelin <jquelin@gmail.com>
Sun, 16 Nov 2008 09:26:14 +0000 (16 10:26 +0100)
committerJérôme Quelin <jquelin@gmail.com>
Sun, 16 Nov 2008 09:26:14 +0000 (16 10:26 +0100)
treeee5cb6d46838fe93e9e5ef180212c9fbef98718e
parent774675c07acccc45fdf4454c376d753d5f0e50d2
try to stick with befunge specs regarding fingerprints semantics

> in that sense, i *guess* you expect that befunge do:
>  - before:      bind r to ROMA-M
>  - load ROMA:   push r to M save-stack, bind M to ROMA-M
>  - load MODU:   push ROMA-M to M save-stack, bind M to MODU-M
>  - unload ROMA: pop ROMA-M from M save-stack, bind M to ROMA-M
>
> but this is counter-intuitive: unloading ROMA should not leave a ROMA
> semantic (unless there are 2 ROMAs loaded, of course)...
>
> especially since you don't touch the top most fingerprint, so one can
> expect that the top most fingerprint is always there.

The key words there are 'push onto a stack' and 'pop from a stack'. Each
instruction A-Z is a stack of semantics. Each fingerprint is a list of
(letter,semantic) pairs. When popping, only the letter is looked at, not the
semantic. Looking at M:

Initial                   -- M: []
Load ROMA                 -- M: [ROMA]
Load MODU                 -- M: [ROMA,MODU]
Unload ROMA (pop CDILMVX) -- M: [ROMA]
Unload MODU (pop MRU)     -- M: []

For instance, unloading NULL is equivalent to popping a semantic from each
instruction.

The most relevant part of the spec here:

> The corresponding ) "Unload Semantics" instruction unloads the semantics for
> a given fingerprint from any or all of the instructions A to Z (even if that
> fingerprint had never been loaded before).

Note *even if that fingerprint had never been loaded before*. ) doesn't care
what semantics the instructions are currently bound to, it just pops the top one
lib/Language/Befunge/IP.pm
lib/Language/Befunge/Ops.pm