Re: CREATE
- From: Elizabeth D Rather <erather@xxxxxxxxx>
- Date: Tue, 21 Jul 2009 13:43:01 -1000
Harold wrote:
....
With regards to CREATE, I think that the decision to merge <BUILDS
into CREATE unnecessarily restricts certain implementation techniques.
Consider an architecture that has a limited number of one-byte fast
subroutine call instructions, e.g. the Intel 8080 RST, or the RCA 1802
SEP instructions. In a direct-threaded implementation, these one-byte
calls can be dedicated to the run-time semantics of the most common
defining words like CONSTANT, VARIABLE, USER, and docolon. But you
can't compile a one-byte call for a CREATE'd object, because you don't
know whether or not its runtime semantics are going to be overridden
by a later occurring DOES>. So a CREATE'd object has to be compiled as
a more general (i.e. larger and slower) subroutine call instruction
with a modifiable destination address, typically 3 or more bytes long.
If the default runtime semantics of a CREATE'd object are never
overridden with a later DOES>, this wastes space and time.
In the old Fig-Forth days, the word <BUILDS was a signal to the
compiler that there would be a following DOES>, so it needed to be
compiled with the more general subroutine call instruction that could
be overridden. On the other hand, the Fig-Forth CREATE couldn't be
followed by DOES>, so the compiler could use a (faster) one-byte
subroutine call instruction, actually the same runtime semantics as
VARIABLE. The only difference being that, at compile time, VARIABLE
also does a CELL ALLOT.
The decision to merge <BUILDS into CREATE prevents this sort of
optimization. ANSI Forth is usually pretty good at precluding
different implementation techniques, so I wonder whether the
standardization committee considered this issue when the decision was
made to eliminate <BUILDS.
Yes, it was considered at length. That is, in fact, the reason that DOES> is defined to work only with CREATE, so VARIABLE, CONSTANT, and other defining words can be optimized differently without penalty. When it became common practice to implement DOES> with a CALL instead of the longer formulations previously common, it was no longer considered necessarily to have an extra word just to prepare for DOES>.
Cheers,
Elizabeth
--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
==================================================
.
- Follow-Ups:
- Re: CREATE
- From: Jean-Francois Couture
- Re: CREATE
- From: Harold
- Re: CREATE
- References:
- CREATE
- From: MarkWills
- Re: CREATE
- From: Andrew Haley
- Re: CREATE
- From: MarkWills
- Re: CREATE
- From: Coos Haak
- Re: CREATE
- From: Elizabeth D Rather
- Re: CREATE
- From: MarkWills
- Re: CREATE
- From: Elizabeth D Rather
- Re: CREATE
- From: MarkWills
- Re: CREATE
- From: Elizabeth D Rather
- Re: CREATE
- From: Harold
- CREATE
- Prev by Date: Re: CREATE
- Next by Date: Re: CREATE
- Previous by thread: Re: CREATE
- Next by thread: Re: CREATE
- Index(es):
Relevant Pages
|
Loading