Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #1544
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Subject | Re: String Constants |
| Newsgroups | comp.lang.forth |
| References | (3 earlier) <EOmdnfzW8ZdkNSzQnZ2dnUVZ_gidnZ2d@supernews.com> <0242bcd1-96f9-41ad-9d32-de4f94a549c7@x37g2000prb.googlegroups.com> <lcSdnduu5oeiEy_QnZ2dnUVZ_qGdnZ2d@supernews.com> <2011Apr23.134428@mips.complang.tuwien.ac.at> <M5udnTCdvYU9ny7QnZ2dnUVZ_uWdnZ2d@supernews.com> |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Date | 2011-04-26 09:23 +0000 |
| Message-ID | <2011Apr26.112307@mips.complang.tuwien.ac.at> (permalink) |
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>>BruceMcF <agila61@netscape.net> wrote:
>>>And neither would I, but when writing portable programs that will run
>>>on systems you've never seen and may not yet exist, it makes sense to
>>>apply Postel's principle:
>>>
>>>Be conservative in what you send; be liberal in what you accept.
>>
>> Maybe so, but that's not a good basis for designing standards.
>
>No, but it's a really, really good way to write portable programs.
Maybe. But writing programs to comply with an interpretation of a
standard that cannot be tested without implementing a new system (the
"devil's system") is not practical and therefore not a good way; it
also does not increase the real-world portability in any way.
>>>Which, in this case, means that if you program for "the devil's
>>>implementation" of Forth, one that satisfies the letter of the law,
>>>but is as perversely written as possible, your program will be robust
>>>even in the presence of occasional foibles of implementation.
>>
>> Sure, that may be heaven for language lawyers, but in practice most
>> programmers write programs such that they work on the real systems
>> they expect their program to be used with.
>
>This has nothing to do with language lawyers, but about writing robust
>portable programs.
"Letter of the law" has everything to do with language lawyers.
It also has nothing to do with writing robust portable programs. As
an example, in classical C,
n<n-1
is an efficient test for checking whether x was the smallest number of
its type (and that's even true for ones-complement and sign-magnitude
arithmetic). In ANSI C, this is only guaranteed for unsigned numbers,
and gcc -O, the devil's implementation, goes ahead and "optimizes"
this to "0". Now a language lawyer told me that I could write
n < (long)(((unsigned long)n)-1)
instead to get the C compiler to produce the code I want while
"satisfying the letter of the law". So I try this with the devil's
implementation and find: gcc 2.95, 3.3 and 3.4 all produce 0 with -O
for both code variants and produce the intended code (apart from quite
a bit of inefficiency) without -O for both variants of the code. Only
gcc 4.1 (among the gcc versions I tested) works as the language lawyer
promised.
In conclusion, I did not get a robust and portable program by
satisfying the letter of the law.
>> And that's the sane approach, because there is no test whether a
>> program will work on a "devil's implementation". E.g., As a result,
>> most portable Forth code assumes 1 chars=1, because all maintained
>> systems implement that, we cannot test code that tries to cater for
>> the "devil's system" in this area.
>
>That's good practice: it makes sense to program for a somewhat
>modified standard, with 1 chars=1.
And in all maintained systems UNUSED bytes after here are accessible,
so anything else cannot be tested.
>> If you change the standard in the way you suggested ("I'd simply make
>> it clear that using HERE before it was allotted was nonstandard"),
>> there would be no way for programmers to test whether their program
>> violates this restriction.
>
>You can't test for portability on a single system anyway, so this is a
>complete red herring.
I am not sure why you bring up a red herring only to denounce it as
such. To be clear: Nobody but you has talked about testing on a
single system.
- 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 2010: http://www.euroforth.org/ef10/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-18 20:52 -0700
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-19 03:44 -0500
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-21 21:34 -0700
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-22 03:20 -0500
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-22 07:37 -0700
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-22 11:12 -0500
Re: String Constants anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-22 17:36 +0000
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-22 13:05 -0500
Re: String Constants anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-22 18:17 +0000
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-23 03:22 -0500
Re: String Constants anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-23 11:35 +0000
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-23 11:37 -0500
Re: String Constants anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-23 12:07 +0000
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-23 11:40 -0500
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-22 12:22 -0700
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-22 12:13 -0700
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-23 03:30 -0500
Re: String Constants anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-23 11:44 +0000
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-23 11:47 -0500
Re: String Constants anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-26 09:23 +0000
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-26 06:49 -0500
Re: String Constants Paul Rubin <no.email@nospam.invalid> - 2011-04-25 00:50 -0700
Re: String Constants anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-26 10:08 +0000
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-23 10:14 -0700
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-24 03:15 -0500
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-24 13:26 -0700
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-24 17:03 -0500
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-24 19:05 -0700
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-25 03:08 -0500
Re: String Constants kenney@cix.compulink.co.uk - 2011-04-25 07:07 -0500
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-25 08:00 -0700
Re: String Constants Elizabeth D Rather <erather@forth.com> - 2011-04-25 08:56 -1000
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-25 07:45 -0700
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-26 03:42 -0500
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-26 11:20 -0700
Re: String Constants Alex McDonald <blog@rivadpm.com> - 2011-04-26 11:02 -0700
Re: String Constants Bernd Paysan <bernd.paysan@gmx.de> - 2011-04-26 21:59 +0200
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-27 03:26 -0500
Re: String Constants Alex McDonald <blog@rivadpm.com> - 2011-04-27 09:12 -0700
Re: String Constants Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-27 11:28 -0500
Re: String Constants Alex McDonald <blog@rivadpm.com> - 2011-04-27 10:47 -0700
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-27 10:20 -0700
Re: String Constants BruceMcF <agila61@netscape.net> - 2011-04-22 12:37 -0700
csiph-web