Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #14718

Re: Is this example in the Forth200x draft 11.1 correct?

From "Rod Pemberton" <do_not_have@notemailnot.cmm>
Newsgroups comp.lang.forth
Subject Re: Is this example in the Forth200x draft 11.1 correct?
Date 2012-08-04 04:33 -0400
Organization Aioe.org NNTP Server
Message-ID <jvimkv$44f$1@speranza.aioe.org> (permalink)
References <jvhbrh$ca8$1@speranza.aioe.org> <5094667.sii35MTXpt@sunwukong.fritz.box> <jvhj73$sjs$1@speranza.aioe.org> <13444064.4VEzN2xdTr@sunwukong.fritz.box>

Show all headers | View raw


"Bernd Paysan" <bernd.paysan@gmx.de> wrote in message
news:13444064.4VEzN2xdTr@sunwukong.fritz.box...
> Rod Pemberton wrote:
...

> > Doesn't COMPILE, store an xt for _all_ future uses?
>
> No, it is to compile the xt into a definition.

"compiling the xt" is what , (comma) is supposed to be doing in the example.
Isn't it?  ['] returns an XT.  But, as you've stated COMPILE, is for doing
that.

> > Isn't that the
> > stated
> > purpose of using COMPILE, instead of , (comma) to store XT's?  If not,
> > what's the point of COMPILE, ?
>
> The point of COMPILE, is to append the xt to the current definition,
> which may be native code, and therefore does not store the xt in a form
> that can be easily retrieved again (especially not with @).
>

If ['] returns an XT on the stack as is required, then an XT is not native
code.

> If you store an xt to be retrieved by @, then , is perfectly fine, and
> COMPILE, utterly broken.  You can try with bigForth, VFX or SwiftForth,
> all three systems completely fail when you replace the , in the DEFER
> code with COMPILE,.

What you're saying is that COMPILE, didn't replace , (comma) for storing
XTs into definitions...  COMPILE, is used under other select circumstances.
That changes my understanding of what COMPILE, is used for.

So, COMPILE, for a native code Forth is used to inline the native code
routine for a Forth word corresponding to a specific XT into a definition.
That means that COMPILE, can only be used for the current definition or in a
another definition via POSTPONE.  For a interpreted Forth, COMPILE, just
stores the XT into the definition.

If use of an XT is delayed for later use by >BODY or EXECUTE or even
COMPILE, then , (comma) or ! (store) etc must be used to save the XT.

It seems that you're using 'xt' as being equivalent to the XT's code
sequence.  I.e., by "compile the xt" you mean inline the code routine for
the XT for native code Forths.  Whereas, "compile the xt" also means storing
the XT into a definition for interpreted Forths.  Both "compile the xt"...
Yes?

Why do native code Forth's need to inline the code sequence for a specific
XT for COMPILE, at all?  Can't the code sequence be called instead - e.g.,
procedure or subroutine?  Also, why can't COMPILE, be defined in terms of
EXECUTE and a stored XT?  That should work for both kinds of Forths
without need of inlining any code...

Perhaps ...
: COMPILE,  ['] LIT , , POSTPONE EXECUTE ;

LIT's not ANS...

John Hayes posted these for ANS:
: COMPILE, POSTPONE LITERAL POSTPONE EXECUTE ;
: [COMPILE] ' COMPILE, ; IMMEDIATE

 (I'll have to relocate the post if desired)

Won't Hayes' COMPILE, work correctly without ever inlining the code
sequence for a specific XT?

I think it does and the overhead seems insignificant.  It also seems to
eliminate any need for COMPILE, in the first place...  His COMPILE,
definition stores the XT for use with EXECUTE.  There is no inlining
required or needed.


Rod Pemberton


Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Is this example in the Forth200x draft 11.1 correct? "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-08-03 16:23 -0400
  Is this example in the Forth200x draft 11.1 correct? Mark Wills <markrobertwills@yahoo.co.uk> - 2012-08-03 13:49 -0700
  Re: Is this example in the Forth200x draft 11.1 correct? Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-03 23:07 +0200
    Re: Is this example in the Forth200x draft 11.1 correct? "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-08-03 18:28 -0400
      Re: Is this example in the Forth200x draft 11.1 correct? Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-04 02:49 +0200
        Re: Is this example in the Forth200x draft 11.1 correct? "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-08-04 04:33 -0400
          Re: Is this example in the Forth200x draft 11.1 correct? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-08-04 04:37 -0500
  Re: Is this example in the Forth200x draft 11.1 correct? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-06 21:27 -0700
    Re: Is this example in the Forth200x draft 11.1 correct? Howerd <howerdo@yahoo.co.uk> - 2012-08-07 00:04 -0700
    Re: Is this example in the Forth200x draft 11.1 correct? "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-08-07 05:05 -0400
      Re: Is this example in the Forth200x draft 11.1 correct? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-07 14:18 +0000
        Re: Is this example in the Forth200x draft 11.1 correct? Alex McDonald <blog@rivadpm.com> - 2012-08-07 09:39 -0700
          Re: Is this example in the Forth200x draft 11.1 correct? Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-07 20:20 +0200
            Re: Is this example in the Forth200x draft 11.1 correct? Alex McDonald <blog@rivadpm.com> - 2012-08-07 12:31 -0700
              Re: Is this example in the Forth200x draft 11.1 correct? Alex McDonald <blog@rivadpm.com> - 2012-08-07 13:26 -0700
                Re: Is this example in the Forth200x draft 11.1 correct? Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-08 00:49 +0200
            Re: Is this example in the Forth200x draft 11.1 correct? Alex McDonald <blog@rivadpm.com> - 2012-08-07 12:33 -0700
          Re: Is this example in the Forth200x draft 11.1 correct? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-08 07:21 +0000
          Re: Is this example in the Forth200x draft 11.1 correct? Mark Wills <markrobertwills@yahoo.co.uk> - 2012-08-08 01:12 -0700
            Re: Is this example in the Forth200x draft 11.1 correct? Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-08 19:11 +0200
        Re: Is this example in the Forth200x draft 11.1 correct? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-07 19:29 -0700
        Re: Is this example in the Forth200x draft 11.1 correct? Elizabeth D Rather <erather@forth.com> - 2012-08-07 22:01 -0500
          Re: Is this example in the Forth200x draft 11.1 correct? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-07 20:07 -0700
            Re: Is this example in the Forth200x draft 11.1 correct? Elizabeth D Rather <erather@forth.com> - 2012-08-07 23:03 -0500
          Re: Is this example in the Forth200x draft 11.1 correct? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-08 07:42 +0000
            Re: Is this example in the Forth200x draft 11.1 correct? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-08 18:12 -0700
              Re: Is this example in the Forth200x draft 11.1 correct? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-08 18:59 -0700
              Re: Is this example in the Forth200x draft 11.1 correct? Mark Wills <markrobertwills@yahoo.co.uk> - 2012-08-09 02:30 -0700
                Re: Is this example in the Forth200x draft 11.1 correct? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-09 09:48 +0000
                Re: Is this example in the Forth200x draft 11.1 correct? Percy <percival.andrews@gmail.com> - 2012-08-10 06:33 -0700
                Re: Is this example in the Forth200x draft 11.1 correct? "David N. Williams" <williams@umich.edu> - 2012-08-10 09:58 -0400
                Re: Is this example in the Forth200x draft 11.1 correct? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-10 15:39 +0000
                Re: Is this example in the Forth200x draft 11.1 correct? "David N. Williams" <williams@umich.edu> - 2012-08-10 16:15 -0400
                Re: Is this example in the Forth200x draft 11.1 correct? percival.andrews@gmail.com - 2012-08-10 16:42 -0700
                Re: Is this example in the Forth200x draft 11.1 correct? Coos Haak <chforth@hccnet.nl> - 2012-08-11 01:51 +0200
                Re: Is this example in the Forth200x draft 11.1 correct? George Hubert <georgeahubert@yahoo.co.uk> - 2012-08-11 06:25 -0700
                Re: Is this example in the Forth200x draft 11.1 correct? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-11 09:12 +0000
                Re: Is this example in the Forth200x draft 11.1 correct? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-13 14:28 -0700
                Re: Is this example in the Forth200x draft 11.1 correct? Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-14 00:51 +0200
                Re: Is this example in the Forth200x draft 11.1 correct? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-13 16:24 -0700
                Re: Is this example in the Forth200x draft 11.1 correct? Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-14 03:25 +0200
                Re: Is this example in the Forth200x draft 11.1 correct? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-14 07:54 -0700
                Re: Is this example in the Forth200x draft 11.1 correct? Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-14 23:22 +0200
                Re: Is this example in the Forth200x draft 11.1 correct? hughaguilar96@yahoo.com - 2012-08-16 00:37 -0700
      Re: Is this example in the Forth200x draft 11.1 correct? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-07 19:30 -0700

csiph-web