News for hackers. Stuff that matters.
Re:Forth by ajhenrydev on Monday July 27, 2026 @05:18PM (#49075649)
Can someone explain for me?
Re:Forth by e12e on Monday July 27, 2026 @05:53PM (#49075966)
A different way to say the same: in forth, words get pushed on the stack, and popped from the stack by words that take arguments:

    code           stack
    I Forth love

    Forth love     I

    love           I
                   Forth

    ; love presumably pops
    ; subject, object args
    ; from stack - and does something 
    ; perhaps prints as side effect
Re:Forth by DonHopkins on Monday July 27, 2026 @08:00PM (#49077381)
Here is some inexplicably but meticulously formatted FORTH code that uses right justified indentation! Including reverse polish notation assembley.

https://donhopkins.com/home/code/tomt-cam-forth-scr.txt

https://donhopkins.com/home/code/tomt-users-forth-scr.txt

  ( FMOVE -- functional intersegment move                   ) HEX

  88 CONSTANT *MOV*  ( fn = 0 )   20 CONSTANT *AND*  ( fn = 1 )
  08 CONSTANT  *OR*  ( fn = 2 )   30 CONSTANT *XOR*  ( fn = 3 )

  CODE FMOVE ( fn s.seg s.off d.seg d.off length --)  AX, SI MOV
      CX POP  DI POP  ES POP  SI POP  DS POP  DX POP  AX PUSH
                        AL, # *XOR* MOV  DX, # 3 CMP  1$ JE
                        AL, #  *OR* MOV  DX, # 2 CMP  1$ JE
                        AL, # *AND* MOV  DX, # 1 CMP  1$ JE
                        AL, # *MOV* MOV               1$:
     CS: HERE 5 + , AL MOV  ( modify "[DI], AL MOV" ) 2$:
                      LODS  ES: [DI], AL MOV  DI INC  2$ LOOP
      AX, CS MOV  ES, AX MOV  DS, AX MOV  SI POP  NEXT,  END-CODE

                                                            -->
Re:Forth by forsalebypwner on Monday July 27, 2026 @07:20PM (#49076908)
Is that loss?
Re:Forth by joshu on Monday July 27, 2026 @09:06PM (#49077949)
well played
Re:Forth by fwip on Monday July 27, 2026 @09:31PM (#49078148)
No.
Re:Forth by e12e on Sunday August 02, 2026 @12:18PM (#49145876)
Actually the stack is wrong here, after pushing two words, the sequence should be:

    Forth
    I
Re:Forth by spott on Monday July 27, 2026 @05:22PM (#49075689)
Forth I assume uses reverse polish notation: arguments before the operator.

3 4 +

for example, would return 7.

Re:Forth by argimenes on Monday July 27, 2026 @06:38PM (#49076395)
The stack is really a convenience that makes pipeline-driven programming possible in the language.
Re:Forth by nagaiaida on Monday July 27, 2026 @11:08PM (#49078785)
somewhat relatedly, shell pipelining is very amenable to being massaged into (non stack-based) concatenative programming
Re:Forth by zabzonk on Monday July 27, 2026 @06:03PM (#49076058)
> would return 7

more pedantically, it would push 7 onto the stack

Re:Forth by dbcurtis on Monday July 27, 2026 @07:28PM (#49077000)
even more pedantically, would remove 3 and 4 from the stack before pushing 7
Re:Forth by DonHopkins on Monday July 27, 2026 @08:07PM (#49077449)
Even oddly more pedantically, that's the operand stack, not to be confused with the separate return stack. >R and R> move values between the two stacks.

On the other hand, PostScript also has a dictionary stack, which you can use to implement a Smalltalk-like object oriented programming system. And its data types and executable code are basically polymorphic homoiconic JSON (like Lisp), not raw untyped bytes like FORTH.

https://news.ycombinator.com/item?id=22456471

https://news.ycombinator.com/item?id=47812317

Re:Forth by HFguy on Monday July 27, 2026 @05:23PM (#49075706)
Forth uses RPN so the "verb" is last.

That is, you provide the data first (I and Forth) and the command (heart) last.

Re:Forth by ithkuil on Tuesday July 28, 2026 @03:02AM (#49080343)
AKA FJN (Forward Japanese Notation)
Re:Forth by daureg on Monday July 27, 2026 @06:08PM (#49076099)