home .. forth .. colorforth mail list archive ..

[colorforth] yet another colorforth


So my new colorforth dialect is compiling itself, and I've got a couple screen shots up on a website.

http://newscript.org

It differs from Chuck's Colorforth in a number of ways, but owes a huge debt to it in terms of programming philosophy and spirit.  Probably the most significant departure is in how color is applied to words.  Rather than having a bunch of different space bars, I use space, tab, and enter in different combinations to change the case of the word.  This means that whitespace is syntactically significant similar to Python.

There is also some additional grammar that isn't described on the website yet that some people may find fun.  Newscript has no IF THEN or FOR NEXT constructs.  Rather is uses punctuation to designate different mood or tenses: 

	word?	interogative mood, conditional jump
	word.	imperative  mood, unconditional jump
	word,	adjuvantive mood, call & drop
	word;	future tense, push word onto return stack
	word	present tense, call word
	
So branching requires factoring out each branch.  IF ELSE THEN translates roughly to:
	
	thenword; ifword? elseword.

Push the thenword onto the return stack, then if the condition is met jump to ifword (which returns to thenword), or jump to elseword (which then returns to thenword).  So far I've never actually used ; for this purpose, but its there :)

Similarly, variables can have @ and ! appended directly to them in order to compile an immediate fetch or store opcode: (stand alone @ and ! still exist and work as expected)

	word!	locative case,	store at the address of word
	word@	genetive case,	fetch from the address of word

Since the address of word (whatever it might be) is known at compile time, (and compile time can be at run time), these usages only compile the address of word as an immediate value in the x86 instruction.  With the top two items on the data stack stored in registers, the resulting code almost never touches the data stack at all.  As a result, I'm both very happy with the speed of compilation and execution.  But most of all, I love having a color coded forth, with both syntax and grammar! 

Anyways, code will be available soon-ish, as I'd like to put the finishing touches on the OpenGL based editor before releasing it into the wild.  The ncurses interface is useable, but currently requires using a C-bootstrap executable to get running.  Also the Mach-O generation really needs to be rewritten in Newscript, because patching the header is just too prone to breaking when building larger images.

Hope this inspires some people to go out and start playing with their colorforths again!

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com