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


Groups > comp.lang.forth > #54464

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 16:16 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2017Jan27.171653@mips.complang.tuwien.ac.at> (permalink)
References (2 earlier) <urWdnUJubp0_mBfFnZ2dnUU7-dXNnZ2d@supernews.com> <2017Jan26.172625@mips.complang.tuwien.ac.at> <udGdnbkweYIOrBfFnZ2dnUU7-f_NnZ2d@supernews.com> <2017Jan27.101029@mips.complang.tuwien.ac.at> <Pr2dnV0-9prY8xbFnZ2dnUU7-TvNnZ2d@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:
>>>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>>>>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>>>> I expect that maintainence programmers will also be familiar with the
>>>> recognizers used in the programs they maintain.
>>>
>>>Ah.  That's a huge mistake.  I have many times been called to a site
>>>where a mysterious Forth program is malfunctioning, sometimes in very
>>>difficult circumstances.
>> 
>> Then if LOCATE reports an error, you will know that the word is not a
>> definition (or, on some systems, it might be a beheaded definition),
>> and you know it's time to look at the recognizers loaded into the
>> system.  Or you have more comfortable system where LOCATE actually
>> reports the recognizer that recognizes the word.
>
>Yes.  I'm looking at the latter.
>
>>>I don't get it.  Why would anybody type 
>>>
>>>  locate "abc def" 
>> 
>> Why wouldn't they?  When you see
>> 
>> "abc def" type
>> 
>> it's quite obvious that '"abc def"' belong together.
>
>LOCATE parses a word -- by definition separated by spaces -- from the
>input stream.  I am not convinced there would be any benefit in
>changing that for recognizers.

As I explained, it would not hurt if LOCATE was specified to consume
the rest of the line, because in practice people don't put anything
except the stuff they want to LOCATE on the same line.

>> will do something other than you claim you expect: I will not take
>> this complaint seriously unless you have filed a bug report for the
>> SwiftForth implementation of WORDS
>
>OK, so you wouldn't take the complaint seriously.  But it's a bug in
>WORDS, certainly.

Have you reported it?  If you care about other stuff on the same line
after LOCATE (which is not standardized), you should care about other
stuff on the same line after WORDS, no?

My take on this is: Given that apparently nobody has complained about
WORDS in SwiftForth, maybe it is overspecified in the standard.  And
maybe specifying that LOCATE consumes a white-space delimited word
would be an overspecification, too.

>> No, this is Forth, the programmer is responsible.  But apparently not
>> even you can think of a scenario where this would be a problem.
>
>Of course I can, but that's not the point.  For example, if ALLOCATE
>were used to hold a scanned string later to be consumed (and FREEd) by
>one of the methods, a recognizer would leak memory when used by
>LOCATE.

If that is the kind of problem you have in mind, I will accept it
gladly over even the slightest complication of the interface.  My
system will start to use swap space after a few hundred millions of
LOCATE on this kind of recognized string; I couldn't care less.  Guess
what: Gforth's interpreted S" leaks its string every time you invoke
it; nobody has complained yet.  For smaller systems like amForth, if
they have LOCATE at all, and the LOCATE works on recognizers, the user
may have to restart the system after maybe a hundred LOCATEs of such
recognizers; also not a problem that justifies complicating the
interface.

>It might well be that all the proposal needs is some suitable language
>about how recognizers might be invoked, and some advice about how to
>write them in a way that would not cause any problems.  For example, a
>recognizer that scanned strings could use a single buffer, perhaps
>enlarging it if needs be.

I don't think we need this language, because I don't think this is a
problem.  Gforth's string recognizer, just like its S" and its S\",
produces strings that live until the end of the session.  And that's a
feature, not a bug.

However, there are other things that one would not want, such as
changing BASE in the recognizer and changing it back in the methods; I
don't think that anybody would want to do that, but if you think it is
helpful, suggest language that would discourage such usage.

>But if you do that, what about the recursive use of recognizers?  Is
>it legitimate for a recognizer to call DO-RECOGNIZER?

Yes.  An example would be '->Myline.end.y' i.e., having the TO
recognizer apply to a word recognized by the dot-parser recognizer.  I
am not sure if we are up to that, yet.  This may be a real problem.

>Dealing with proposals and counter-proposals is similar to a debugging
>process.  Some programmers don't write really tough test cases for
>their programs, and of course, often the world later bites them in the
>arse.  A better technique, which I practice as often as I remember
>(but probably not as much as I should) is to write the most difficult
>stress test I can think of, in the hope that it'll shake out bugs.  Of
>course it doesn't always work, but you'd be a fool not to.

Go ahead, produce test cases that show breakage in the current
recognizer proposal.

>I've often wondered why everybody doesn't do this.  My guess is that
>people are so in love with their creations that they don't want to see
>the flaws.

Yes.  Now the recognizer proposal is not my creation; and the Gforth
implementation is not my creation, either.  OTOH, you show signs of
not seeing the flaws in your arguments.

While I am very fussy about the specifics of words used in portable
programs such as COMPILE, and S", I don't think we need to be as fussy
with respect to programming tools like WORDS, SEE, and LOCATE.  That's
because nobody uses these words in portable programs; they are just
used by programmers during development, and they do what they do, and
programmers adapt their usage to the behaviour of the word.

- 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