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 18 of 21 Topic 3960 of 4053
Post > Topic >>

Re: Is interpret/compile the wrong distinction?

by Josh Grams <josh@[EMAIL PROTECTED] > Mar 24, 2008 at 01:00 PM

Jonah Thomas <jethomas5@[EMAIL PROTECTED]
> wrote:
>
> I think we're on the same wavelength here but I've been fooled before
> sometimes when I thought that about others. 

Ditto. :)

> Let's see. Compile-only. You compile each line and then either execute
> it and discard it, or you leave it added to the dictionary. 

I think you need to compile to a temporary buffer if you're going to
execute and discard it.  e.g. what if the code adds stuff to the
dictionary?

> But you want to have immediate words that execute during compilation.
> And the same words would execute during interpretation, the only
> difference is that it's code that will be executed and thrown away
> instead of saved.

Yup.

> I believe this doesn't actually save you a whole lot (though I could be
> wrong). Forth already has immediate words that execute whether
> interpreting or compiling. And it already has regular words that execute
> in an interpreted line and get compiled in a compiled line. So you need
> interpreted parsing words to parse and save strings that then get acted
> on later, more complex. (But you could throw them way and use the
> compiler versions, so that is a saving.)

Sure.  The only time that I think it saves you trouble is when defining
words with special compilation semantics.  You don't have to write two
versions, like CHAR and [CHAR].  You don't need interpret/compile: and
dual xt dictionaries to try and get the functionality under one name.
You just define the compilation semantics and make it IMMEDIATE, and it
works properly whether or not you're in a definition (I believe).

So maybe not a big win, but I think it's a worthwhile goal.

> You get to use control structures outside of definitions, provided
> they're all on one line.  That's an advantage too.

With the way I'm thinking about implementing it, they can be on multiple
lines, provided that a complete control structure fits into the
temporary compilation buffer.

> When an execution token executes, you're always at the end of a line,
> right? So >IN @[EMAIL PROTECTED]
 will always give the same as SOURCE NIP ? 

Hrm.  I hadn't thought of that one.  So you probably can't use
compile-only as an implementation technique for a completely standard
Forth.

But I don't think anyone ever interprets >IN directly anyway.  Searching
the gforth-cvs sources turns up only occurrences that are compiled into
a parsing word.  So it just means that any word which does parsing needs
to be declared as a parsing (immediate) word.

> If you get the chance sometimes, you might look at John Doty's LSE64. He
> does something a lot like you want, and he swears by it. If you like it
> I'm sure he'd appreciate somebody paying attention to it.

Yeah, I've looked at LSE64.  But it's designed so as to have no
immediates at all.  I think that being able to define new syntax is a
very useful tool, and I don't have a problem with standard Forth
(mostly).  I just think that when you want the "same" functionality in
both interpret/compile mode, it's silly to have to do things like:

: CHAR BL WORD C@[EMAIL PROTECTED]
 ;
: [CHAR] CHAR POSTPONE LITERAL ; IMMEDIATE

That, in my opinion, is something that the language should do for you.
But it looks like you can't do it without breaking a fair bit of
compatibility.  It might be a fun experiment anyway...

--Josh




 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 Fri May 16 7:25:22 CDT 2008.