Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Julian Fondren Newsgroups: comp.lang.forth Subject: Re: Yay! CGI forth interpreter success Date: Sat, 30 Jul 2011 16:03:57 -0500 Organization: A noiseless patient Spider Lines: 105 Message-ID: <86mxfv4h1e.fsf@gmail.com> References: <89389716-8d7a-4de0-a954-ea63584c5522@a12g2000vbf.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: mx04.eternal-september.org; posting-host="cO8zBIpB9LiP7q+vFZIJrA"; logging-data="4130"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NEDQw8q7BMMPIQ7yMnct8HdWbrylILiE=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) Cancel-Lock: sha1:h+4YGHBFYw66gVjL3p8GsdFHva0= sha1:TkHe1VSukiKRV2bld0nNFkrp5rM= Xref: x330-a1.tempe.blueboxinc.net comp.lang.forth:4505 Tarkin writes: > On Jul 25, 8:17 am, Mark Wills wrote: >> On Jul 25, 3:08 am, Tarkin wrote: >> > here is index.4th, a simple, bare-minimum cgi test: >> > --------------------8<---------------------------------------------- >> > \ vim: set ft=forth: set ts=2: >> > : NEWL 13 EMIT 10 EMIT ; >> > ." HTTP/1.1 200 OK" NEWL >> > ." Content-Type: text/html; charset=UTF-8" NEWL >> > ." Connection: close" NEWL >> > ." X-Powered-By: flow-0.9" NEWL >> > NEWL >> > NEWL >> > ." " CR >> > ."   " CR >> > ."     FORTH CGI" CR >> > ."   " CR >> > ."   " CR >> > ."    

It works!

" CR >> > ."    

Hello, Browser!!!
" CR >> > ."     Forth CGI interpreter based on jonesforth, written by >> > Tarkin!!!.

" CR >> > ."   " CR >> > ." " CR >> >> Very very nice! >> >> Given most browsers 'forgiveness' with white space, you could define >> some HTML (at least the earlier ones, from 1.0/1.1) tags as Forth >> words: >> >> :

 ."

"  ; >> :

."

" ; >> > > Yes, that came next in testing! I also wrapped the headers like so: > --------------------------8<------------------------------------------ > : .H1 ." HTTP/1.1 200 OK" NEWL; > : .H2 ." Content-Type: text/html; charset=utf-8" NEWL ; > : .H3 ." Connection: close" NEWL ; > : .H4 ." X-Powered-By: flow-0.9" NEWL ; > : .HTTP .H1 .H2 .H3 .H4 NEWL NEWL ; > \ tags already defined.... > > > flow CGI > > >

It works!

This is 'Hello, browser!' > for forth CGI!

> > Are you really using Forth's text interpreter, here? There's no space after for it to be recognized as a word. If you're not using Forth at this point, how will you embed any Forth logic? If you've extended the interpreter so that <title> is pulled off and then allowed to do its own parsing of the bare ` flow CGI ' that follows, how does its parser know to interpret some text as Forth? I think of : title ." flow CGI" ; <html> <head> <title> title ( <-- executed.)

.( It works!)

You get a mileage from hitting space a few extra times. It's suddenly clear what's Forth and what isn't; you don't have to do anything special to switch between HTML and Forth; porting becomes a matter of a prelude with some definitions, rather than having to (temporarily?) extend or duplicate or hack the system's text interpreter. And rather than having to edit the code to insert the spaces, which is an irritation for version control. > \ it might be my impl. but this seems backward for ! (STORE)... > 3 ARRAY NUMS > R1 0 NUMS ! > R2 1 NUMS ! > R3 2 NUMS ! ! ( x a-addr -- ) NUMS ( u -- a-addr ) What seems backwards? > : ROWS > 0 > BEGIN > 2DUP = IF 2DROP EXIT THEN > DUP 1+ SWAP DUP 48 + EMIT NUMS @ DUP STRLEN > TELL > AGAIN > ; [char] 0 + \ clearer (.) \ works for two-digit numbers. : rows ( n -- ) \ is this so awful? 0 ?do i (.) type \ may want a 1+ here i nums @ dup strlen tell loop ;