Replies: 1 comment
-
A tiny comment (I did not parse your entire message yet):
Rather than ABORT, better call NOTFOUND.
mån 27 jan. 2025 kl. 08:40 skrev ekipan ***@***.***>:
… It is perhaps desirable for hide to abort instead of silently failing
<e33627c>
if the word isn't found. defcode does so, and in fact it uses the same parse-name
> find-name > notfound phrase that see does, which I will factor into name.
If we compute the destination address by subtracting from the next name
instead of adding to the old latest then we can also reuse the address
calculation from defcode:
\ wordlist.fs
: name ( "name" -- nt )
parse-name 2dup find-name ?dup 0=if notfound then nip nip ;
: cfa ( nt -- cfa ) count $1f and + ;
: hide name dup latest -( size ) >r cfa 2+ r@ - ( dsta )
latest swap dup to latest r> move ;
: defcode here name cfa ! ;
: define defcode ] ;
hide name hide cfa
With this implementation we could also extract a word to hide a whole
range of names at once!
( ... )
: hidden ( nt1 nt2 -- ) latest -( size ) >r cfa 2+ r@ - ( dsta )
latest swap dup to latest r> move ;
: hide name dup hidden ;
: hidethru name name hidden ;( ... )
I actually came upon this coming from the other direction: I wanted a word
to hide a range of names at once and ended up with similar code to the
current wordlist.fs hide. Well yeah that makes sense. A small diagram
that helped me to write it in the first place:
: a ; : b ; : c ; : d ;
: e ; : f ; : g ; : h ;
hidethru c e ( hide c hide d hide e )
\ v-oldlatest\ ------ <- words to move\ h-g-f-e d c b a <- old wordlist\ -> h-g-f-b a <- new wordlist\ ------ <- moved words\ ^-newlatest
The name hidethru brings to mind the block wordset thru, since the two
names form an inclusive range. I personally might prefer to bikeshed a name
like hides tho.
—
Reply to this email directly, view it on GitHub
<#595>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAY34OZFPUV6IXS2HY4JWF32MXPIRAVCNFSM6AAAAABV5NSKDCVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZXHA3TSNRTGU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It is perhaps desirable for
hide
to abort instead of silently failing if the word isn't found.defcode
does so, and in fact it uses the sameparse-name > find-name > notfound
phrase thatsee
does, which I will factor intoname
. If we compute the destination address by subtracting from the next name instead of adding to the oldlatest
then we can also reuse the address calculation fromdefcode
:With this implementation we could also extract a word to hide a whole range of names at once!
I actually came upon this coming from the other direction: I wanted a word to hide a range of names at once and ended up with similar code to the current wordlist.fs
hide
. Well yeah that makes sense. A small diagram that helped me to write it in the first place:The name
hidethru
brings to mind the block wordsetthru
, since the two names form an inclusive range. I personally might prefer to bikeshed a name likehides
tho.Beta Was this translation helpful? Give feedback.
All reactions