News for hackers. Stuff that matters.
Re:Starting Forth – the classic Forth language tutorial by draegtun on Thursday June 20, 2013 @10:12AM (#5912151)
>re: ... and only use whitespace to separate the 'words'?

Have a look at Rebol which is a mix of Forth, Logo & Lisp.

Here's an example of Rebol code (typed into the console (REPL))...

  >> multiply add 1 2 3
  == 9
multiply and add are both functions which take two arguments. If I add parens then above becomes clearer.

  >> multiply (add 1 2) 3
  == 9
So Rebol evaluates a list of words from left to right with non-variadic functions (ie. they have fixed argument arity).

Here's an example of a conditional:

  >> if equal? 1 1 [print "1 is 1!!"]
  1 is 1!!
if is a function which takes two arguments (as is equal?). So this is code is evaluated like this:

  >> equal? 1 1
  == true

  >> [print "1 is 1!!"]
  == [print "1 is 1!!"]
If the first argument is true (which it is in this case!) then the second argument (which is a block) is evaluated...

  >> do [print "1 is 1!!"]
  1 is 1!!

There are no comments on this comment yet.