FORTH is an abomination

I was forced to look at some FORTH code this morning. My brain is permanently damaged. FORTH is an abomination, whatever advantages it may apparently hold.

 \ Note 1: Text after a backslash is a comment until end-of-line.
 \ Note 2: Text within parentheses like "( n -- )" is also a comment.
 \ Note 3: To be strictly ANSI compliant, the code below is in UPPERCASE.
 \	 Most PC Forth implementations are (optionally) case insensitive.

 : STAR	 ( -- ) \ Print a single star
   42 EMIT ;	  \ 42 is the ASCII code for *

 : STARS	( n -- ) \ Print n stars
   0 DO STAR LOOP ;	\ Loop n times (0 up to n-1) and execute STAR

 : SQUARE	( n -- ) \ Print an n-line square of stars
   DUP 0 DO		\ Loop n times, keeping (DUP-licating) n on the stack
   DUP STARS CR	\ Each time, print n stars then print CR
   LOOP DROP ;	\ After loop is done, drop the n from the stack

It appears to have all the drawbacks of ASM with few of the benefits. Why not just use BEFUNGE?

Advertisements

Join the discussion...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s