Replies: 4 comments 6 replies
-
I'm not fussed much. Though I would have named things like For me, I more naturally think But Forth naming style has always seemed rather odd to me. Its probably what makes it hard to understand for some. Cryptic names vs descriptive. |
Beta Was this translation helpful? Give feedback.
-
DROPS Especially useful in the phrase DO I DROPS LOOP |
Beta Was this translation helpful? Give feedback.
-
Since it is non-standard, you can name it anything you want. It's your word; name it whatever is most clear to you. If it was up to me, I'd name it "drop-n" ... I append a "-n" to the name if I want to have the word do it some number of times. That is my style. Yours may very well be different, and that is 100% OK. I wouldn't stress out over it. :) |
Beta Was this translation helpful? Give feedback.
-
I asked chatgpt for a short word, meaning "drop multiple items", and it came up with:
While I tend to name the implementation of such a word "ndrop", I dislike its non-orthogonality with, say, roll vs. rot - according the same pattern, roll should be nrot, rotn, or rots, but instead, a genuine word was chosen, rather than such a synthetical strung together word creation. But I didn't care much about it, due to my very infrequent use: if a word benefits from "ndrop", there may be better ways to write it, either by better factoring (in case a constant count of many items needs to be dropped) or by avoiding stack effects which require keeping track of variable item counts. Asking chatgpt for an alternative suggestion, it came up with "shed":
I like that one. |
Beta Was this translation helpful? Give feedback.
-
Many systems/libraries define a word that drops a specified number of items from the data stack.
This word has a stack diagram
( +n.cnt*x +n.cnt -- )
.In the wild, the names «
ndrop
» and «dropn
» are found for this word. Maybe something else?The question is what is a better name for this word.
Among the standard words, a word that consumes and/or produce a different data type than some base word is typically named after the base word by adding a short prefix to its name. This rule is also used when parameters are passed indirectly, only formally (like in
fdepth
), or only somehow associated (like infalign
).Some examples:
abs
dabs
,fabs
+
d+
,f+
<
u<
,f<
aligned
faligned
depth
fdepth
drop
fdrop
>r
n>r
r>
nr>
So I think the name
ndrop
is more appropriate for the word in question.A portable (not efficient) implementation for this word looks like this:
A similar word that removes a specified number of items from the floating point stack should probably be named as
nfdrop
, afterfdrop
:Are you agree or disagree?
Beta Was this translation helpful? Give feedback.
All reactions