Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #54459

Re: Recognizers and LOCATE

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Recognizers and LOCATE
Date 2017-01-27 11:37 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2017Jan27.123706@mips.complang.tuwien.ac.at> (permalink)
References (6 earlier) <cdWdnSHgZ-G1dxTFnZ2dnUU7-S_NnZ2d@supernews.com> <2017Jan26.163930@mips.complang.tuwien.ac.at> <QK2dnd0vUbLHsxfFnZ2dnUU7-TvNnZ2d@supernews.com> <2017Jan27.093738@mips.complang.tuwien.ac.at> <7O2dndTFzbzEjxbFnZ2dnUU7-f3NnZ2d@supernews.com>

Show all headers | View raw


Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>
>>>But in the example I cited there is no way for the reader to be able
>>>to tell that what they're looking at is not a name in the
>>>dictionary.  I suppose you could argue that the same is true for dot
>>>parsers, but then that's a black mark against dot parsers, IMO.
>>>Having said that, dot parsers aren't being proposed for
>>>standardization and their syntax seems to me to be quite distinctive
>>>and therefore quite benign.
>> 
>> And I expect the same to be true of all successful recognizers, and
>> the existing system-specific recognizers demonstrate this.
>
>But you have already described one recognizer (for TO) for which this
>certainly is not true.

I find a "->" prefix quite distinctive.

Looking at the example from <http://www.forth200x.org/locals.html>:

: foo  {: a b | c d -- :}
   a b + to c
   a b * to d
   cr c .  d .
;

If we use the TO-recognizer instead of TO, it becomes

: foo  {: a b | c d -- :}
   a b + ->c
   a b * ->d
   cr c .  d .
;

Looks pretty obvious and certainly distinctive to me.

Concerning distinctiveness, let's see how often names with that prefix
occur:

In the 85319 lines of .fth files delivered with the Vfxlin Evaluation
version, there are 0 occurences of '->' as a prefix.  Interestingly,
-> (as a separate word) occurs a lot, as a synonym of TO.  So,
certainly for VFX users, ->bla should be quite suggestive.

In the 78671 lines of .f file delivered with SwiftForth, there are 71
occurences of -> as a prefix (find . -name \*.f|xargs grep --
'[[:space:]]->[^[:space:]]'), all in unsupported/fslib/.

In the 94326 lines of .fs files in my gforth directory, there are 28
occurences of -> as a prefix, all of them by Bernd Paysan, who also
chose the syntax ->NAME as TO replacement.

So there is some usage of a -> prefix in ordinary Forth names, and
maybe ->NAME is not the best pattern for a TO recognizer, or maybe the
conflicts are acceptable.  I think that it is still a distinctive
pattern.

An alternative TO recognizer would be to actually recognize TO and
then parse the next name and then work with that.  I.e., TO <name>.

Advantages over ->NAME: Standard syntax; no conflicts with ->NAME
names.

Disadvantages compared to ->NAME: When you do POSTPONE ->NAME, it's
clear that ->NAME is one unit; for POSTPONE TO NAME, it isn't; this is
not a problem for ]] ... TO NAME ... [[, though.  For this reason, I
avoid parsing recognizers when we have a good alternative (i.e., in
most cases).

Advantages over existing implementations of TO: No corner cases with
'/['] (just doesn't work), works as expected for ]] ... TO NAME
... [[.

Disadvantages over existing implementations of TO: If a program
contains a use of POSTPONE TO (non-standard, but possibly existing),
introducing a TO NAME recognizer will probably break it.

In any case, either the ->NAME syntax will catch on, then you will be
unlikely to be confused by it, or it won't, then you will be unlikely
to encounter it.  In the unlikely case that you encounter it but have
already forgotten about it not being the name of a definition, if you
LOCATE it, and LOCATE tells you it does not find it, you will know
that you are dealing with a recognized word; or you are on a friendly
system that actually tells you that this is recognized by the TO
recognizer.

>It wasn't my idea.  And it's an example of
>precisely the problem that I'm anticipating, not a product of my
>overheated imagination.

The claim that a -> prefix is not distinctive is a product of your
imagination.

>> You are proposing to complicate the proposal
>
>Not at all: I suspect that if this proposal were designed well it
>should be possible to accomodate things such as LOCATE well without
>greatly complicating it.  But it's hard to retro-fit such things once
>the proposal is in wide use.

Give examples of how you would change the interface, and before-after
comparisons of a few recognizers.

>> You can hook anything into SwiftForth's NOT-DEFINED and into VFX's n
>> interpreter hooks, so they are not constrained at all, and certainly
>> not in the form of strings that they can recognize.
>
>You can, but they are not widely used, precisely because they are
>internal and system-secific.

As if that has ever kept Forth programmers from using a
system-specific feature.  When Marcel Hendrix gets a standard program
in his fingers, he immediately replaces many words in the code with
iForth-specific equivalents.  Searching for '->' and 'TO' in the VFX
files mentioned above, I find 1198 lines containing '->', more than
the 1057 lines containing TO.

No, the reason why people have not gone overboard with system-specific
recognizers is not that they are system-specific, but that, while
there is a demand for something in that area, as evidenced by the n
hooks in VFX, and repeated discussions on the topic, it is not as
extreme as you imagine.  There will be several general-purpose
recognizers that everybody will be familiar with (maybe including
->NAME, maybe not), and, for specific application areas, specific
recognizers (say, 25°8'13" for dealing with angles); the latter should
be obvious to anyone working in the application area, i.e., hopefully
your maintenance programmer; it would still be cool if the system
provided a LOCATE that says that this is recognized by REC:ANGLE).

>> We know how the feature works out in practice, because the feature is
>> present in all Forth systems.
>
>Actually, no, it is not, as I have explained.  Several times.

I must have missed these explanations.  The only explanations I have
seen are those where you want to make us believe that people don't use
features unless they are standardized.  Which does not combine well
with your other stance that one should establish common practice
before standardization (unless, of course, the goal is never to
standardize anything).

>> And in any case, LOCATE can be implemented to work for recognizers as
>> currently proposed.
>
>No, because of side effects, as I have explained.

The one side effect that exists in practice (changing >IN) is actually
a good idea, and you have not come up with other side effects.

>> Sure.  What side effects do you have in mind?  And does anybody
>> care?
>
>Anything.  I think so.  I'm a careful and conservative engineer whose
>first reaction to any proposal, no matter where it comes from, is
>"What adverse effects might this have?"  You need people like that.

That's fine.  I have examined your concerns, and they don't have
enough weight to justify complicating the interface.  Especially since
you neither give examples of the side effects you fear, nor have you
shown that your interface changes do not complicate the recognizer
definitions.

- 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


Thread

Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-24 12:38 -0600
  Recognizers and LOCATE JennyB <jennybrien@googlemail.com> - 2017-01-24 10:56 -0800
    Re: Recognizers and LOCATE Bernd Paysan <bernd@net2o.de> - 2017-01-24 22:25 +0000
      Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-25 03:16 -0600
        Re: Recognizers and LOCATE JennyB <jennybrien@googlemail.com> - 2017-01-25 08:37 -0800
          Re: Recognizers and LOCATE Alex <alex@rivadpm.com> - 2017-01-25 14:22 -0500
            Re: Recognizers and LOCATE Alex <alex@rivadpm.com> - 2017-01-25 14:26 -0500
            Re: Recognizers and LOCATE Matthias Trute <matthias.trute@gmail.com> - 2017-01-25 11:49 -0800
              Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-26 03:33 -0600
                Re: Recognizers and LOCATE Matthias Trute <matthias.trute@gmail.com> - 2017-01-26 10:14 -0800
                Re: Recognizers and LOCATE JennyB <jennybrien@googlemail.com> - 2017-01-26 11:04 -0800
            Re: Recognizers and LOCATE Bernd Paysan <bernd@net2o.de> - 2017-01-26 01:24 +0000
              Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-26 06:26 -0600
                Re: Recognizers and LOCATE Bernd Paysan <bernd@net2o.de> - 2017-03-12 00:47 +0000
                Re: Recognizers and LOCATE albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-03-12 17:01 +0100
                Re: Recognizers and LOCATE Matthias Trute <matthias.trute@gmail.com> - 2017-03-13 12:31 -0700
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-14 04:51 -0500
                Re: Recognizers and LOCATE Matthias Trute <matthias.trute@gmail.com> - 2017-03-14 12:48 -0700
              Re: Recognizers and LOCATE Alex <alex@rivadpm.com> - 2017-01-27 17:18 +0000
                Re: Recognizers and LOCATE Matthias Trute <matthias.trute@gmail.com> - 2017-01-27 09:28 -0800
                Re: Recognizers and LOCATE Alex <alex@rivadpm.com> - 2017-01-27 17:35 +0000
                Re: Recognizers and LOCATE Matthias Trute <matthias.trute@gmail.com> - 2017-01-28 04:29 -0800
        Re: Recognizers and LOCATE Bernd Paysan <bernd@net2o.de> - 2017-01-25 21:07 +0000
          Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-26 11:24 +0000
            Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-26 06:23 -0600
              Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-26 15:39 +0000
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-26 11:14 -0600
                Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-27 08:37 +0000
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-27 03:26 -0600
                Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-27 11:37 +0000
                Re: Recognizers and LOCATE stephen@mpeforth.com (Stephen Pelc) - 2017-01-27 17:28 +0000
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-28 04:22 -0600
                Re: Recognizers and LOCATE Matthias Trute <matthias.trute@gmail.com> - 2017-01-28 04:35 -0800
                Re: Recognizers and LOCATE JennyB <jennybrien@googlemail.com> - 2017-01-28 07:03 -0800
                Re: Recognizers and LOCATE Matthias Trute <matthias.trute@gmail.com> - 2017-01-28 07:42 -0800
                Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-28 17:25 +0000
                Re: Recognizers and LOCATE peter.m.falth@gmail.com - 2017-01-28 08:05 -0800
                Re: Recognizers and LOCATE JennyB <jennybrien@googlemail.com> - 2017-01-28 09:27 -0800
                Re: Recognizers and LOCATE albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-28 19:18 +0100
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-29 04:35 -0600
                Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-29 16:59 +0000
                Re: Recognizers and LOCATE albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-29 19:40 +0100
                Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-31 17:01 +0000
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-31 04:12 -0600
                Re: Recognizers and LOCATE Bernd Paysan <bernd@net2o.de> - 2017-03-12 01:25 +0000
                Re: Recognizers and LOCATE minforth@arcor.de - 2017-03-12 01:30 -0800
                Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-12 10:07 +0000
                Re: Recognizers and LOCATE Bernd Paysan <bernd@net2o.de> - 2017-03-15 23:30 +0000
                Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-16 11:59 +0000
                Re: Recognizers and LOCATE Bernd Paysan <bernd@net2o.de> - 2017-03-17 21:46 +0000
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-12 06:51 -0500
                Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-12 13:05 +0000
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-12 12:04 -0500
  Re: Recognizers and LOCATE albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-24 20:41 +0100
  Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-26 11:52 +0000
    Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-26 08:20 -0600
      Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-26 16:26 +0000
        Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-26 11:27 -0600
          Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-27 09:10 +0000
            Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-27 09:59 -0600
              Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-27 16:16 +0000
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-28 04:35 -0600
                Re: Recognizers and LOCATE albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-28 19:41 +0100
                Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-29 16:18 +0000
                Re: Recognizers and LOCATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-01-31 04:21 -0600
                Re: Recognizers and LOCATE Bernd Paysan <bernd@net2o.de> - 2017-03-12 01:07 +0000
    Re: Recognizers and LOCATE albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-26 21:08 +0100
      Re: Recognizers and LOCATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-27 10:13 +0000

csiph-web