|
|
Up |
|
|
  |
Author: Anton ErtlAnton Ertl Date: Aug 29, 2008 05:20
If a Forth system supports local buffers (or another locals extension
that produces addresses of local memory, e.g., Gforth's
variable-flavoured locals), then it has to define the lifetime of the
memory the address points to. Typically the lifetime will be until
the end of the definition that the buffer was defined in.
This inhibits tail-call optimization; consider:
: bar ( addr -- )
... ;
: foo { | [ 1 ] x } x bar ;
in the syntax proposed by Stephen Pelc or
: foo 1 lbuffer bar ;
in a syntax suggested by others. The allocated buffer must stay alive
across the call to BAR, because it is used in BAR, so the deallocation
of the buffer must happen after the call to BAR, and BAR is no longer
a tail-call and can therefore not be optimized.
Consider the contrast to ordinary (value-flavoured locals):
: flip { a } a bar ;
|
| Show full article (1.67Kb) |
|
| | 5 Comments |
|
  |
Author: Stephen PelcStephen Pelc Date: Aug 29, 2008 07:34
>If a Forth system supports local buffers (or another locals extension
>that produces addresses of local memory, e.g., Gforth's
>variable-flavoured locals), then it has to define the lifetime of the
>memory the address points to. Typically the lifetime will be until
>the end of the definition that the buffer was defined in.
>
>This inhibits tail-call optimization; consider:
>
>: bar ( addr -- )
> ... ;
>
>: foo { | [ 1 ] x } x bar ;
>
>in the syntax proposed by Stephen Pelc or
>
>: foo 1 lbuffer bar ;
|
| Show full article (1.60Kb) |
|
| | no comments |
|
  |
Author: Anton ErtlAnton Ertl Date: Aug 30, 2008 01:02
>>If a Forth system supports local buffers (or another locals extension
>>that produces addresses of local memory, e.g., Gforth's
>>variable-flavoured locals), then it has to define the lifetime of the
>>memory the address points to. Typically the lifetime will be until
>>the end of the definition that the buffer was defined in.
>>
>>This inhibits tail-call optimization; consider:
>>
>>: bar ( addr -- )
>> ... ;
>>
>>: foo { | [ 1 ] x } x bar ;
>>
>>in the syntax proposed by Stephen Pelc or
>>
>>: foo 1 lbuffer bar ; ...
|
| Show full article (2.14Kb) |
| no comments |
|
  |
Author: Peter FälthPeter Fälth Date: Aug 30, 2008 01:49
>
>>>If a Forth system supports local buffers (or another locals extension
>>>that produces addresses of local memory, e.g., Gforth's
>>>variable-flavoured locals), then it has to define the lifetime of the
>>>memory the address points to. Typically the lifetime will be until
>>>the end of the definition that the buffer was defined in.
>
>>>This inhibits tail-call optimization; consider:
>
>>>: bar ( addr -- )
>>> ... ;
>
>>>: foo { | [ 1 ] x } x bar ;
>
>>>in the syntax proposed by Stephen Pelc or ...
|
| Show full article (3.85Kb) |
| no comments |
|
  |
Author: Andrew HaleyAndrew Haley Date: Sep 3, 2008 11:22
Anton Ertl mips.complang.tuwien.ac.at> wrote:
> If a Forth system supports local buffers (or another locals extension
> that produces addresses of local memory, e.g., Gforth's
> variable-flavoured locals), then it has to define the lifetime of the
> memory the address points to. Typically the lifetime will be until
> the end of the definition that the buffer was defined in.
> This inhibits tail-call optimization; consider:
> : bar ( addr -- )
> ... ;
> : foo { | [ 1 ] x } x bar ;
> in the syntax proposed by Stephen Pelc or
> : foo 1 lbuffer bar ;
> in a syntax suggested by others. The allocated buffer must stay
> alive across the call to BAR, because it is used in BAR, so the
> deallocation of the buffer must happen after the call to BAR, and
> BAR is no longer a tail-call and can therefore not be optimized.
|
| Show full article (1.13Kb) |
| no comments |
|
  |
|
|
  |
Author: Albert van der HorstAlbert van der Horst Date: Sep 4, 2008 11:07
In article supernews.com>,
Andrew Haley wrote:
>Anton Ertl mips.complang.tuwien.ac.at> wrote:
>> If a Forth system supports local buffers (or another locals extension
>> that produces addresses of local memory, e.g., Gforth's
>> variable-flavoured locals), then it has to define the lifetime of the
>> memory the address points to. Typically the lifetime will be until
>> the end of the definition that the buffer was defined in.
>
>> This inhibits tail-call optimization; consider:
>
>> : bar ( addr -- )
>> ... ;
>
>> : foo { | [ 1 ] x } x bar ;
>
>> in the syntax proposed by Stephen Pelc or
>
>> : foo 1 lbuffer bar ;
> ...
|
| Show full article (2.06Kb) |
| no comments |
|
|