on the OLPC wiki, there's NIP ( a b -- b ) and TUCK ( a b -- b a b ) and -ROT ( a b c -- c a b ) which I call LROT, but what is the word which has the stack diagram ( a b c -- b a c ) ? Is it UNDER?
I hope the name UNDER does not get confused with UNDER+ which has the stack effect ( a b c -- a+c b ). I don't remember where I saw UNDER+ , but I've found it useful and included it in Fleet Forth's kernel since day one.
I think many have all the combinations out to 5 letters (CAAAR).
Almost right - Common Lisp has up to 6 letters (i.e, sequences of A's and D's up to length 4). That makes up 2^1+2^2+2^3+2^4 = 30 of Common Lisp's set of 978 symbols.
I don't think it would be practical, even feasible. There are many different stack operations you can do, and most of them can be defined using others. The standard operations have names related to their functions, because the functions are simple.
I think that what chitselb means is that every stack manipulation should have a name, not that every conceivable stack manipulation (no matter how rarely used) should be implemented in a Forth system. It is a simple matter to write a CODE word for any manipulation that isn't in your Forth system but is likely to be used a lot in a program. I have often found 2PICK to be such a word.
Yes and your favorites could be kept available in source form.
Quote:
programandala.net wrote:
That's the problem I just mentioned. It would be hard to remember not only which one is `flop` and which one is `flip`, but also what they actually do!
for "flop" I would probably use ROTSWAP if I needed the word or SWAPUNDER if the former name was not descriptive enough.
"flip" would probably sound better as 3REVERSE. (I hope I didn't get "flip" and "flop" mixed up. )
I believe FLIP is ROT SWAP , and I agree, ROTSWAP is a better name. It has the virtue of telling what it does just like DUP>R takes the place of DUP>R .
Mike, the TLM's you propose are valid hex numbers. Could get (a little too) interesting...
It should be fine in Forth since the dictionary is searched first, and #INT is only called if something wasn't found in the dictionary, to see if it's a valid number in the current base. So for example FACE, BAD, FEED, DEAD, ADD, and other such names, if defined, would never be confused for a hex number either.
I realize I could go with something like 2.PICK but a name with a dot in it ( if it's not used for numeric output ) seems more appropriate for SamCoVT's idea of organizing constant names around what they go to.
Sadly, the Commodore 64 lacks the underscore character.
Early Forths used the hyphen for that function, and it has carried into modern Forths too. I think the underscore character works better though. For characters that aren't on the keyboard, many systems offer easy ways to type them in. When I'm in my MultiEdit [1] editor, I hold <Alt> while typing the three-digit decimal DOS/ANSI [Edit: that should say IBM437] character number, like 248 for the ° symbol or 241 for the ± symbol. The ones I use most often I remember; but <Alt>A (for "ASCII," even though real ASCII ends at 127) brings up the chart for when I don't remember the number.
[1] Edit, 8/9/25: I just found out, from the Wikipedia article that MultiEdit is defunct, due to the heart-attack death of the man who really made it go, and that even the website has been gone since Aug 2022.
Not only is the underscore character not on the C64 keyboard, it is not even in the PETSCII character set.
I like the idea of 2PICK being syntactically equivalent to 2 PICK while DPICK is the double number version of PICK .
I just checked the documentation for Mosaic Forth versions 4.0 and 4.2 .
The stack effect for DPICK is this.
DPICK ( d wn-1 . . . w1 w0 +n -- d wn-1 . . . w1 w0 d )
The documentation states that it copies the double number whose most significant cell is nth item on the data stack ( 0-based not including n) to the top of the stack.
0 DPICK is equivalent to 2DUP
2 DPICK is equivalent to 2OVER
1 DPICK will copy a double number that is just below a single number
( d w -- d w d )
Not only is the underscore character not on the C64 keyboard, it is not even in the PETSCII character set.
Does the ROM get copied to RAM, such that you can alter the character set? My HP-71 lets you load in different character sets, telling it what dots to turn on for each; so although it comes with the ROMAN-8 set as standard, I did the DOS/ANSI [Edit: that should say IBM437] set since I now always use Epson dot-matrix printers with it.
Not only is the underscore character not on the C64 keyboard, it is not even in the PETSCII character set.
Does the ROM get copied to RAM, such that you can alter the character set? My HP-71 lets you load in different character sets, telling it what dots to turn on for each; so although it comes with the ROMAN-8 set as standard, I did the DOS/ANSI set since I now always use Epson dot-matrix printers with it.
Code 95 of "_" is the left arrow character on a C64 (PETSCII-Code). It doesn't look nice, but the character is displayed and can be typed in.
Someone might redefine this character to a "_" to get the "real" feeling.