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


Groups > comp.lang.forth > #1081

Re: Implementation of execute-parsing-file

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Subject Re: Implementation of execute-parsing-file
Newsgroups comp.lang.forth
References (5 earlier) <47e2ba82-7653-46c9-85a6-73d31e715f8d@32g2000vbe.googlegroups.com> <4d9d8f99$0$11751$882e7ee2@usenet-news.net> <2995683f-b76e-4544-9cda-a2e6f7ad37a7@k30g2000yqb.googlegroups.com> <2011Apr7.183251@mips.complang.tuwien.ac.at> <d5839e54-1805-4556-92dc-ce5ffbb13f93@k9g2000yqi.googlegroups.com>
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Date 2011-04-09 13:10 +0000
Message-ID <2011Apr9.151054@mips.complang.tuwien.ac.at> (permalink)

Show all headers | View raw


BruceMcF <agila61@netscape.net> writes:
>On Apr 7, 12:32=A0pm, an...@mips.complang.tuwien.ac.at (Anton Ertl)
>wrote:
>> BruceMcF <agil...@netscape.net> writes:
>> >On Apr 7, 6:19=3DA0am, Josh Grams <j...@qualdan.com> wrote:
>> >> Hrm. =3DA0I'd argue the other way on that. =3DA0It's *less* reliable, =
>as it's
>> >> late binding, so if the evaluated string is defined in a different pla=
>ce
>> >> than where it's used, you have to worry about whether all the names ha=
>ve
>> >> the expected meaning.
>>
>> >Its as late or early binding as you wish it to be, since it can of
>> >course be:
>> > =A0 S" EXECUTE" INCLUDE-WITH foo.fs
>> >or
>> > =A0 S" foo.fs" R/O OPEN-FILE THROW
>> > =A0 S" EXECUTE" INCLUDE-FILE-WITH
>>
>> That would late-bind EXECUTE. =A0There are workarounds for this kind of
>> misdesign (look at the standard implementation of EXECUTE-PARSING),
>> but it's better to avoid the misdesign than to work around it.
>
>Yes, if EXECUTE is not executed on a standard system, it will indeed
>not have standard effects. But if you do not know what the words you
>call will do, then you don't know what execute-parsing-file will do
>either, so that argument seems to be a bit empty.

As a programmer, I generally know what the words visible during
compilation do, but I have no influence on what will be visible at
run-time.  Consider:

: foo1 ... ['] bar execute-parsing-file ... ;
: foo2 ... s" bar" include-file-with ... ;
: foo3 ... ['] bar s" execute" include-file-with ;

And consider the case that one of these words will be called (maybe
through some intermediate layer) from an application word written by
someone else in some sealed application vocabulary, like this:

: flip ... foo? ... ;
...
: flop ... flip ... ;

wordlist constant app-wl
app-wl set-current

: app-word ... flop ... ;

app-wl 1 set-context \ seal the whole thing

and now the user types APP-WORD.  If FOO1 was used, everything works
nicely, whereas with FOO2 and FOO3 the user will most likely get an
"undefined word" error message (or worse, the program might use a
different word than the programmer had in mind).

An advice frequently given here is "Don't do this!".  And I agree:
Don't use late binding for referencing words that you know at compile
time.  And don't design words such that they require late binding.

>> Also, with a string to EVALUATE the current input source would be the
>> string, not the FILE, and it would be very messy both in the
>> specification and in the implementation to let a parsing word in the
>> string parse the file.
>
>In what way is it messy?

Write a specification and compare it to a specification for
EXECUTE-PARSING-FILE.  Write tests, especially for corner cases.
Implement it on several systems, and see how much effort it is, and
how many bugs crop up.

>When either a word in the input source or the
>Forth interpreter at the end of the input source does a REFILL, you
>get the first line of the file and you keep getting lines of the file
>until/unless you return to evaluating, you go to the end of the file.

So, the parsing word that you pass is required to start off with a
REFILL in order to parse anything from the actual file?  Even more
messyness than I originally was thinking of.

Also, this approach requires additional complications if the system
just mmaps the file into memory and is designed for then processing
this memory image sequentially (I don't know if there is any such
system, though).

- 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 | NextPrevious in thread | Next in thread | Find similar


Thread

Implementation of execute-parsing-file Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-04-05 10:50 +0100
  Re: Implementation of execute-parsing-file David Kuehling <dvdkhlng@gmx.de> - 2011-04-05 11:58 +0200
    Re: Implementation of execute-parsing-file Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-04-05 12:26 +0100
      Re: Implementation of execute-parsing-file Josh Grams <josh@qualdan.com> - 2011-04-05 22:35 +0000
        Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-05 18:31 -0700
          Re: Implementation of execute-parsing-file Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-04-06 10:15 +0100
            Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-06 09:04 -0700
              Re: Implementation of execute-parsing-file Josh Grams <josh@qualdan.com> - 2011-04-07 10:19 +0000
                Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-07 07:54 -0700
                Re: Implementation of execute-parsing-file anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-07 16:32 +0000
                Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-08 18:22 -0700
                Re: Implementation of execute-parsing-file anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-09 13:10 +0000
                Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-09 12:43 -0700
                Re: Implementation of execute-parsing-file anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-10 13:22 +0000
                Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-10 09:44 -0700
                Re: Implementation of execute-parsing-file anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-11 14:22 +0000
                Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-11 08:37 -0700
                Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-11 09:05 -0700
                Re: Implementation of execute-parsing-file anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-13 16:50 +0000
                Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-13 12:37 -0700
                Re: Implementation of execute-parsing-file Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-10 02:55 -0500
                Re: Implementation of execute-parsing-file anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-10 13:11 +0000
                Re: Implementation of execute-parsing-file Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-10 09:27 -0500
                Re: Implementation of execute-parsing-file anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-11 14:11 +0000
                Re: Implementation of execute-parsing-file Doug Hoffman <glidedog@gmail.com> - 2011-04-07 11:46 -0400
                Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-08 18:24 -0700
                Re: Implementation of execute-parsing-file Doug Hoffman <glidedog@gmail.com> - 2011-04-09 02:53 -0400
                Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-09 13:01 -0700
            Re: Implementation of execute-parsing-file BruceMcF <agila61@netscape.net> - 2011-04-06 09:14 -0700
        Re: Implementation of execute-parsing-file Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-04-06 10:15 +0100

csiph-web