Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #48705
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: RfD: new double syntax |
| Date | 2016-07-02 14:54 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2016Jul2.165431@mips.complang.tuwien.ac.at> (permalink) |
| References | <2016Jul1.191836@mips.complang.tuwien.ac.at> <98422a5e-4421-4d8f-83e0-760ba7e90c74@googlegroups.com> |
Julian Fondren <julian.fondren@gmail.com> writes:
>On Friday, July 1, 2016 at 12:26:50 PM UTC-5, Anton Ertl wrote:
>> Problem
>> -------
>>
>> People coming from other languages expect "1." to be a floating-point
>> number.
>>
>
>Ruby:
>
> $ irb
> irb(main):001:0> 1
> => 1
> irb(main):002:0> 1.0
> => 1.0
> irb(main):003:0> 1.
> irb(main):004:0*
>
>There's no "=>" and result output at this point because Ruby doesn't
>consider 1. to be a complete expression.
If all languages worked like this, "1." would not be a problem.
However, many languages consider "1." as a floating point number, and
that's where the expectations of many Forth newcomers are formed.
E.g.:
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 1.
1.0
GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>1. =
1.0
>To trip, you must first have forward movement. When someone thinks
>they've learned Forth, starts writing a program, and then runs into a
>confusing error -- that's a "trip".
That's pretty much what is happening here.
> Floating point syntax is something
>that you can only get wrong before you know the language well enough to
>be doing much beyond flipping to the next page of a tutorial.
Not everybody learns a language by flipping pages of a tutorial.
>If you have some demoralizing historical explanation, why do you have
>it? There's a time for historical footnotes and there's a time to
>simply describe circumstances as they are right now.
When you describe what is there now without giving an explanation, the
language looks even worse than wehen you give the "demoralizing
historical explanation".
>In Ruby you must write 1.0; you can't just write 1. -- because that's
>something else.
>
>In Forth you must write 1e; you can't just write 1. -- because that's
>something else.
I don't know how well it turns out in Ruby (probably not very well),
but in your example at least one gets immediate feedback that
something is wrong, unlike with 1. in Forth.
Anyway, yes, other languages are not immune to stupid syntax, either;
an example is Edinburgh Prolog's clause syntax, especially because
that's a mistake that the original Marseille Prolog did not make.
>Programming languages vary enormously by syntax, especially in the
>details, even when the languages overall have a very similar appearance.
>Someone coming from other languages can be expected to know that.
There is not that much variation in floating-point syntax. If a
language does not accept "1." as floating-point number, it certainly
does not accept it as something else. Except Forth.
>System Doubles Floats
>CURRENT 1. 1e
>PROPOSED *1 1e
>FUTURE *1 1.
[...]
>Suppose that you had TRADITIONAL-NUMBERS and NATURAL-NUMBERS as words
>that changed the recognizer stack between the CURRENT and SYSTEM numbers
>from above, respectively. This would be annoying for all the same
>reasons BASE is today. Still, isn't it better than simply breaking all
>traditionally-written code?
There are certainly transition strategies for existing code:
If you want to keep the code as-is, you could have something like
TRADITIONAL-NUMBERS (an environmental query would be better, because
it also works on old systems). A way to switch back to the PROPOSED
syntax would indeed introduce the problems that BASE gives us now, so
I would not recommend adding that.
If you want to change the source code to comply with the PROPOSED
syntax, run it through a converter.
>And wouldn't every system that tries to
>break traditionally-written code as you propose end up *also* writing in
>a TRADITIONAL-NUMBERS word in somewhere, that may itself vary from
>system to system as with WARNING vs. WARNINGS today?
If we want a standard way to re-enable the "1.-is-a-double" syntax, we
can certainly standardize that. Anybody who does that hopefully knows
what they are doing, but the newcomers would get an error from
1. instead of an unexpected, seemingly successful result.
>I see only harm coming from adoption of this proposal. I challenge
>anyone to attempt to thoroughly list the surprising differences between
>Forth and most languages today, and then to sort that list in any way
>that results in this proposal standing out as especially appealing or
>worthwhile.
The "1. is a double" is certainly the one that sticks out in my
teaching experience as being both nasty (because it's a silent
surprise), and not at all instructive in any way. For comparison,
another frequent mistake is
."hello, world"
but it results in an error message and it illustrates that ." is just
a word, not some build-in syntax.
- 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 2016: http://www.euroforth.org/ef16/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-01 17:18 +0000
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-01 11:45 -0700
Re: RfD: new double syntax rickman <gnuarm@gmail.com> - 2016-07-01 14:46 -0400
Re: RfD: new double syntax Julian Fondren <julian.fondren@gmail.com> - 2016-07-01 11:47 -0700
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-02 14:54 +0000
Re: RfD: new double syntax mhx@iae.nl - 2016-07-01 11:48 -0700
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-02 14:52 +0000
Re: RfD: new double syntax "Elizabeth D. Rather" <erather@forth.com> - 2016-07-01 09:10 -1000
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-01 19:10 -0700
Re: RfD: new double syntax "WJ" <w_a_x_man@yahoo.com> - 2016-07-02 06:23 +0000
RfD: new double syntax krishna.myneni@ccreweb.org - 2016-07-01 20:54 -0700
RfD: new double syntax krishna.myneni@ccreweb.org - 2016-07-01 21:18 -0700
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-01 22:26 -0700
Re: RfD: new double syntax "WJ" <w_a_x_man@yahoo.com> - 2016-07-02 22:32 +0000
Re: RfD: new double syntax rickman <gnuarm@gmail.com> - 2016-07-03 01:16 -0400
Re: RfD: new double syntax Ron Aaron <rambamist@gmail.com> - 2016-07-03 08:34 +0300
Re: RfD: new double syntax rickman <gnuarm@gmail.com> - 2016-07-03 03:00 -0400
Re: RfD: new double syntax Ron Aaron <rambamist@gmail.com> - 2016-07-03 10:20 +0300
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-03 08:29 +0000
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-02 23:10 -0700
Re: RfD: new double syntax Raimond Dragomir <raimond.dragomir@gmail.com> - 2016-07-02 23:20 -0700
Re: RfD: new double syntax rickman <gnuarm@gmail.com> - 2016-07-03 03:02 -0400
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-02 14:20 +0000
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-02 14:11 +0000
Re: RfD: new double syntax josv@planet.nl - 2016-07-02 00:26 -0700
Re: RfD: new double syntax "Elizabeth D. Rather" <erather@forth.com> - 2016-07-01 22:22 -1000
Re: RfD: new double syntax "HAA" <someone@microsoft.com> - 2016-07-02 22:02 +1000
Re: RfD: new double syntax "Elizabeth D. Rather" <erather@forth.com> - 2016-07-02 11:19 -1000
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-02 14:02 +0000
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-07-02 04:03 -0500
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-02 13:44 +0000
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-02 07:38 -0700
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-02 07:42 -0700
Re: RfD: new double syntax "WJ" <w_a_x_man@yahoo.com> - 2016-07-02 22:44 +0000
Re: RfD: new double syntax Cecil Bayona <cbayona@cbayona.com> - 2016-07-02 09:58 -0500
Re: RfD: new double syntax "Elizabeth D. Rather" <erather@forth.com> - 2016-07-02 11:32 -1000
Re: RfD: new double syntax "WJ" <w_a_x_man@yahoo.com> - 2016-07-03 00:27 +0000
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-04 08:05 -0700
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-07-04 03:50 -0500
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-07-04 03:53 -0500
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-02 17:32 +0000
Re: RfD: new double syntax Julian Fondren <julian.fondren@gmail.com> - 2016-07-02 10:52 -0700
Re: RfD: new double syntax krishna.myneni@ccreweb.org - 2016-07-02 13:03 -0700
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-03 15:02 +0000
Re: RfD: new double syntax Julian Fondren <julian.fondren@gmail.com> - 2016-07-03 11:18 -0700
Re: RfD: new double syntax Coos Haak <chforth@hccnet.nl> - 2016-07-03 21:19 +0200
Re: RfD: new double syntax Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-07-03 11:36 +0100
Re: RfD: new double syntax Gerard Sontag <gerardsontag@gmail.com> - 2016-07-03 06:58 -0700
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-03 14:21 +0000
Re: RfD: new double syntax Gerard Sontag <gerardsontag@gmail.com> - 2016-07-03 07:55 -0700
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-03 08:08 -0700
Dealing with multiple recognizers (was: RfD: new double syntax) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-03 15:13 +0000
Re: Dealing with multiple recognizers (was: RfD: new double syntax) hughaguilar96@gmail.com - 2016-07-03 09:57 -0700
Re: RfD: new double syntax rickman <gnuarm@gmail.com> - 2016-07-05 01:12 -0400
Re: RfD: new double syntax Gerard Sontag <gerardsontag@gmail.com> - 2016-07-05 07:56 -0700
Re: RfD: new double syntax rickman <gnuarm@gmail.com> - 2016-07-05 11:18 -0400
Re: RfD: new double syntax JennyB <jennybrien@googlemail.com> - 2016-07-03 08:15 -0700
Re: RfD: new double syntax Cecil Bayona <cbayona@cbayona.com> - 2016-07-03 12:42 -0500
Re: RfD: new double syntax "Elizabeth D. Rather" <erather@forth.com> - 2016-07-03 09:32 -1000
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-04 07:34 -0700
Re: RfD: new double syntax Julian Fondren <julian.fondren@gmail.com> - 2016-07-04 10:35 -0700
Re: RfD: new double syntax Julian Fondren <julian.fondren@gmail.com> - 2016-07-04 09:00 -0700
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-07-04 09:51 -0700
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-07-04 11:20 -0500
Re: RfD: new double syntax Howerd <howerdo@yahoo.co.uk> - 2016-07-06 04:08 -0700
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-07-06 06:24 -0500
Re: RfD: new double syntax Alex McDonald <alex@rivadpm.com> - 2016-07-06 12:38 +0100
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-07-06 06:46 -0500
Re: RfD: new double syntax Howerd <howerdo@yahoo.co.uk> - 2016-07-06 13:37 -0700
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-07-07 03:28 -0500
Re: RfD: new double syntax Bernd Paysan <bernd.paysan@gmx.de> - 2016-08-04 23:59 +0000
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-08-04 19:26 -0500
Re: RfD: new double syntax Paul Rubin <no.email@nospam.invalid> - 2016-08-04 17:34 -0700
Re: RfD: new double syntax franck.bensusan@gmail.com - 2016-08-05 02:57 -0700
Re: RfD: new double syntax Paul Rubin <no.email@nospam.invalid> - 2016-08-05 13:15 -0700
Re: RfD: new double syntax franck.bensusan@gmail.com - 2016-08-06 01:56 -0700
Re: RfD: new double syntax Paul Rubin <no.email@nospam.invalid> - 2016-08-07 17:22 -0700
Re: RfD: new double syntax franck.bensusan@gmail.com - 2016-08-08 04:56 -0700
Re: RfD: new double syntax josv@planet.nl - 2016-08-08 08:50 -0700
Re: RfD: new double syntax franck.bensusan@gmail.com - 2016-08-08 12:26 -0700
Re: RfD: new double syntax josv@planet.nl - 2016-08-08 15:41 -0700
Re: RfD: new double syntax mhx@iae.nl - 2016-08-08 23:06 -0700
Re: RfD: new double syntax josv@planet.nl - 2016-08-09 00:57 -0700
Re: RfD: new double syntax franck.bensusan@gmail.com - 2016-08-09 03:05 -0700
Re: RfD: new double syntax hughaguilar96@gmail.com - 2016-08-10 01:46 -0700
Re: RfD: new double syntax Paul Rubin <no.email@nospam.invalid> - 2016-08-10 19:07 -0700
Re: RfD: new double syntax franck.bensusan@gmail.com - 2016-08-11 05:24 -0700
Re: RfD: new double syntax josv@planet.nl - 2016-08-06 04:50 -0700
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-08-05 12:01 -0500
Re: RfD: new double syntax Cecil Bayona <cbayona@cbayona.com> - 2016-07-04 08:51 -0500
Re: RfD: new double syntax Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-07-04 04:03 -0500
Re: RfD: new double syntax anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-07-03 14:56 +0000
Re: RfD: new double syntax Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-07-03 22:00 +0100
csiph-web