Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #21373
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Difficulty with Brad Rodriguez' screenful |
| Date | 2013-04-04 13:58 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2013Apr4.155849@mips.complang.tuwien.ac.at> (permalink) |
| References | (8 earlier) <kjajcv$30k$1@online.de> <2013Apr1.185857@mips.complang.tuwien.ac.at> <kjdf8h$1hg$1@online.de> <2013Apr2.161517@mips.complang.tuwien.ac.at> <kjfajr$9n4$1@online.de> |
Bernd Paysan <bernd.paysan@gmx.de> writes:
>Anton Ertl wrote:
>> E.g., C was a portable assembler without return-address manipulation;
>
>That's wrong, too. You can manipulate your return address in C, but the
>usual programs that use that feature is malware, and they use the feature of
>C to allow random input to manipulate the return address ;-). The way to
>manipulate the return address is even "standardized", it's platform
>specific, but it works across all C compilers on one plattform; the thing is
>called ABI.
The malware is platform-specific and the ABI is platform-specific,
i.e., both are not portable, and are therefore not part of
C-as-portable-assembler; we do not use it in Gforth, and even language
implementations where the C control flow was seriously too limited
(e.g., GNU Prolog) have not used it.
>> Or, to get back to Forth, many Forth systems support accessing the
>> stack in memory, and some might think that's a language feature worth
>> supporting in more systems and in a "portable assembler edition" of
>> Forth, but I don't think so.
>
>Even the ANS Forth Standard rationale contains a definition of CATCH and
>THROW that make use of this fact. This is also used in the (not
>standardized) simple multi-tasker which comes with Gforth EC. So why do you
>think this is not something nice to have?
The point of a "portable assembler edition" of Forth would be to have
a portable way to express things that you would otherwise express in
assembly language of the target machine; e.g., to express a
register-to-register addition in the target machine, you would write
"+"; so "+" should correspond to a pseudoregister*-to-pseudoregister
addition, not a memory-to-memory-addition, that can be optimized if
the compiler can prove that the optimization is safe
*) mapping the stack to pseudoregisters (machine-independent) and the
pseudoregisters to registers (machine-dependent) is the compiler's
job.
>> I think that, in a portable assembler edition it's better to make the
>> return addresses that you want to manipulate explicit instead of
>> having all the implicit ones that are generated by calls available for
>> manipulation. That approach may also be a better way for general
>> Forth.
>
>I don't quite see why you call those "implicit".
Because they are created implicitly (automatically). Compare this to
an explicit mechanism like call-with-current-continuation where you
specify explicitly that this is the place that one might return to
outside the usual call-return chain.
>> It's no wonder that the tail-call optimization did not trigger in an
>> example that has no tail calls.
>>
>> Try one that has a tail call:
>>
>> : a r> drop ;
>> : b a ;
>> : c ." <c" b ." c>" ;
>> : d ." <d" c ." d>" ;
>> d
>>
>> Gforth says:
>> <d<cc>d>
>>
>> while SwiftForth says:
>> <d<cd>
>
>IMHO the main reason why early exits and tail call optimizations usually
>don't clash is that it doesn't make sense to call an early-exit word as last
>word.
Yet, Michael Gassanenko has complained that SwiftForth does not work
as he expects wrt. return stack manipulations.
>> And if we do that, we could decide to specify that only codes in a
>> certain range are allowed, leaving open the option to heroically
>> optimize such a CATCH.
>
>I'd expect that most libcc.fs users would throw errno-generated throw codes
>from their C code, because that makes the most sense.
In that case the throw code they should use is IOR(true) (or more
generally IOR(flag), where flag is true if there is an error), which
processes errno so that Gforth produces the right error message.
- 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 2013: http://www.euroforth.org/ef13/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-20 12:03 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-20 18:47 +0100
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-30 16:40 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-01 02:12 +0200
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-01 16:58 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-02 04:20 +0200
Re: Difficulty with Brad Rodriguez' screenful "Elizabeth D. Rather" <erather@forth.com> - 2013-04-01 16:39 -1000
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-02 14:15 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-02 21:12 +0200
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-04 13:58 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-04-02 04:17 -0500
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-02 15:35 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-04-02 16:36 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-03 04:10 +0200
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-04-03 04:03 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-03 21:14 +0200
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-03 16:13 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-04-03 11:54 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-03 22:24 +0200
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-04-04 11:53 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-04 18:13 +0200
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-04 15:53 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-04 22:11 +0200
Re: Difficulty with Brad Rodriguez' screenful Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-04-04 21:35 +0100
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-04 23:06 +0200
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-04-05 10:57 +0000
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-05 14:47 +0000
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-05 14:28 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-06 03:35 +0200
Re: Difficulty with Brad Rodriguez' screenful "Rod Pemberton" <do_not_have@notemailnotq.cpm> - 2013-04-08 23:50 -0400
Re: Difficulty with Brad Rodriguez' screenful "Rod Pemberton" <do_not_have@notemailnotq.cpm> - 2013-04-08 23:49 -0400
Re: Difficulty with Brad Rodriguez' screenful m.a.m.hendrix@tue.nl - 2013-04-05 02:49 -0700
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-05 14:55 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-05 22:05 +0200
csiph-web