Luke Gorrie (lukego) wrote,
Luke Gorrie

Forth school

I went to Forth school with Mitch Bradley yesterday. Here are a few cool new things I learned:
  • many: The word many repeats execution of the current line until a key is pressed.
    ok ." luke rules" cr  many
    luke rules
    luke rules
    luke rules
    ok see many
    : many   
       key? 0= if    
          0 >in ! 
  • quine: Since we can introspect the input stream it's easy to write a program that prints itself to stdout.
    ok ( this is a quine ) source type
    ( this is a quine ) source type
  • patch: The word patch is a simple way to make binary patches to Forth words.
    ok : foo 1 + ;           
    ok see foo
    : foo   
       1 + 
    ok 41 foo .
    ok patch - + foo
    ok see foo
    : foo   
       1 - 
    ok 43 foo .
    ok patch 5 1 foo
    ok see foo
    : foo   
       5 - 
    ok 47 foo .
I love Forth.
Tags: forth, olpc

  • Update: ZSLUG #1 on Tuesday

    Come and enjoy the Zurich Lisp & Stuff User Group on monday! Hans Hübner will tell you about building computers from scratch using FPGAs and I'll…

  • ZSLUG #1: Zurich's new Lisp & Stuff User Group

    Title: Zurich Lisp & Stuff User Group (ZSLUG) rebirth! Date: Monday February 7th, 2011 Time: 7pm onwards Venue: Office of Teclo…

  • Teclo Networks, and, Happy new year

    What a year. I'm finishing 2010 the same way I started it: living in my favourite place in the world, Zurich. (Here's a hint why.) True to form I…

  • Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.