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


Groups > comp.lang.forth > #14822

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

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Is this example in the Forth200x draft 11.1 correct?
Date 2012-08-08 07:21 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2012Aug8.092138@mips.complang.tuwien.ac.at> (permalink)
References <jvhbrh$ca8$1@speranza.aioe.org> <abdc063b-a1be-4839-8724-cd10f8fa37b8@nc9g2000pbc.googlegroups.com> <jvqlka$79p$1@speranza.aioe.org> <2012Aug7.161823@mips.complang.tuwien.ac.at> <90288608-a08e-41b0-99e5-64f04c80b23a@b10g2000vbj.googlegroups.com>

Show all headers | View raw


Alex McDonald <blog@rivadpm.com> writes:
>On Aug 7, 3:18=A0pm, an...@mips.complang.tuwien.ac.at (Anton Ertl)
>wrote:
>
>>
>> Although, DEFERred words used for indirect recursion are not intended
>> to be mutable after the first IS. =A0If there was a way to communicate
>> such information to the Forth system, it could compile code more
>> efficiently.
>>
>
>Could we avoid DEFER and have;
>
>forward foo
>: bar foo ;
>...
>: foolater ... ; ' foolater means foo

We need DEFER for other purposes, and indirect recursion is not
frequent enough to have additional words for that.  What I meant is a
general mechanism that could be used for all CREATE...DOES> words.
Stephen Pelc once suggested a way to declare a memory block as
read-only.  We could then define

: is-final ( xt "name" -- )
  ' >body tuck ! 1 cells read-only ;

and then have

defer foo
: bar ... foo ... ;
: real-foo ... bar ... ;
' real-foo is-final foo

And any further calls to FOO could be compiled to direct calls,
because the compiler could resolve ' FOO >BODY @ at compile time.

Actually, indirect recursion is a bad example for this, because the
most important call to FOO here is in BAR and won't be optimized (and
cannot be optimized with this approach).  A more appropriate example
would be constants or fields:

: constant ( x "name" -- )
  create here swap , 1 cells read-only
does> ( -- x )
  @ ;

: +field ( u1 u2 "name" -- u3 )
  create over here swap , 1 cells read-only +
does> ( addr1 -- addr2 )
  @ + ;

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2012: http://www.euroforth.org/ef12/

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


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