Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: Is interpre...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 21 Topic 3960 of 4065
Post > Topic >>

Re: Is interpret/compile the wrong distinction?

by Elizabeth D Rather <erather@[EMAIL PROTECTED] > Mar 23, 2008 at 03:06 PM

Josh Grams wrote:
> I've been thinking about Jonah Thomas's comment (back toward the
> beginning of this month) that there is a bunch of unnecessary
> complexity around IMMEDIATE/POSTPONE/etc and the divide between
> interpretation and compilation semantics.
> 
> Coming mostly from languages other than Forth, it seems to me that
> the complexity comes from Forth offering the wrong choice to the
> programmer.  I *think* that what I normally want as a programmer
> is a distinction between syntax and semantics (parse time and
> "run" time).

Different names, same concept.  When we speak of "interpretation" we 
mean "parse time".

> For instance, I want the behavior of S" to be: parse a string
> delimited by a double-quote, and add a string literal to the
> current "statement", regardless of whether or not I'm inside a
> definition.

That is precisely what S" as defined in the FILES wordset (as an 
extension to the CORE S") does.

> : CHAR  PARSE-WORD DROP C@[EMAIL PROTECTED]
 LITERAL ; SYNTAX
> : S"  CHAR " PARSE SLITERAL ; SYNTAX

Your word SYNTAX is, IMO, indistinguishable from IMMEDIATE.  And this 
definition of CHAR is what [CHAR] does.  Your S" *doesn't* do what the 
your description above does, in that it won't work if you're *not* 
inside a definition.  A "state-smart" word, that does different things 
depending on whether you're compiling or interpreting, would look like
this:

: S" ( -- addr len )   PARSE  STATE @[EMAIL PROTECTED]
 IF  SLITERAL  THEN ;  IMMEDIATE

> It would, of course, add a bit of complexity to the compiler.  But
> I think it simplifies things for the programmer.  And it has the
> advantage that each name only ever has one piece of code attached
> to it.  And I believe you could have ANS compliance with basically
> just:
> 
> TRUE CONSTANT STATE
> ' SYNTAX ALIAS IMMEDIATE
> 
> I haven't implemented this, and of course I've skipped all the
> details here; I just wanted to present the basic idea.  Thoughts?

I'm very unclear what you think SYNTAX does differently from IMMEDIATE.

In the late 70's a lot of people who were just starting with FORTH 
really liked the idea of "STATE-smart" words, that did different things 
depending on whether you were compiling or interpreting (either compiled 
something or not).  But after a few years' use, most of them came around 
to the understanding that, except in a few specific circumstances, 
STATE-smart words made things *harder* for the programmer, not easier. 
So, whereas in the Forth79 meeting there was a lot of pressure for 
STATE-smart words, by Forth83 and later that was mostly gone.

Cheers,
Elizabeth


-- 
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310-491-3356
5155 W. Rosecrans Ave. #1018  Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================




 21 Posts in Topic:
Is interpret/compile the wrong distinction?
Josh Grams <josh@[EMAI  2008-03-23 14:50:35 
Re: Is interpret/compile the wrong distinction?
Elizabeth D Rather <er  2008-03-23 15:06:31 
Re: Is interpret/compile the wrong distinction?
Bruce McFarling <agila  2008-03-23 14:09:50 
Re: Is interpret/compile the wrong distinction?
Jonah Thomas <jethomas  2008-03-23 19:23:48 
Re: Is interpret/compile the wrong distinction?
pablo reda <pabloreda@  2008-03-23 16:50:53 
Re: Is interpret/compile the wrong distinction?
Albert van der Horst <  2008-03-24 03:20:31 
Re: Is interpret/compile the wrong distinction?
John Doty <jpd@[EMAIL   2008-03-23 22:18:20 
Re: Is interpret/compile the wrong distinction?
Albert van der Horst <  2008-03-24 15:07:47 
Re: Is interpret/compile the wrong distinction?
John Doty <jpd@[EMAIL   2008-03-24 12:36:00 
Re: Is interpret/compile the wrong distinction?
Josh Grams <josh@[EMAI  2008-03-24 01:11:03 
Re: Is interpret/compile the wrong distinction?
Bruce McFarling <agila  2008-03-23 19:34:40 
Re: Is interpret/compile the wrong distinction?
John Doty <jpd@[EMAIL   2008-03-23 22:48:04 
Re: Is interpret/compile the wrong distinction?
Bruce McFarling <agila  2008-03-24 00:06:20 
Re: Is interpret/compile the wrong distinction?
Bruce McFarling <agila  2008-03-24 08:21:38 
Re: Is interpret/compile the wrong distinction?
Bruce McFarling <agila  2008-03-24 09:21:32 
Re: Is interpret/compile the wrong distinction?
Jonah Thomas <jethomas  2008-03-23 20:08:31 
Re: Is interpret/compile the wrong distinction?
Jonah Thomas <jethomas  2008-03-23 22:16:20 
Re: Is interpret/compile the wrong distinction?
Josh Grams <josh@[EMAI  2008-03-24 13:00:48 
Re: Is interpret/compile the wrong distinction?
Jonah Thomas <jethomas  2008-03-24 09:36:52 
Re: Is interpret/compile the wrong distinction?
Albert van der Horst <  2008-03-24 15:40:20 
Re: Is interpret/compile the wrong distinction?
anton@[EMAIL PROTECTED]   2008-03-24 13:41:05 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 4:05:58 CDT 2008.