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


Groups > comp.lang.forth > #50849 > unrolled thread

Given a string, create word with that name (in ANS Forth)?

Started byAlex Dowad <alexinbeijing@gmail.com>
First post2016-09-11 06:12 -0700
Last post2016-09-12 14:08 +0200
Articles 20 on this page of 96 — 19 participants

Back to article view | Back to comp.lang.forth


Contents

  Given a string, create word with that name (in ANS Forth)? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-11 06:12 -0700
    Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-11 10:51 -0500
      Re: Given a string, create word with that name (in ANS Forth)? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-11 09:49 -0700
      Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-11 19:57 +0200
        Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-12 02:43 -0500
      Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-11 14:31 -0700
    Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-11 10:14 -0700
    Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-12 07:46 +0000
      Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-12 01:10 -0700
        Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-12 09:01 +0000
          Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 14:02 +0200
            Re: Given a string, create word with that name (in ANS Forth)? "HAA" <someone@microsoft.com> - 2016-09-20 12:06 +1000
              Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-20 11:27 +0200
          Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-12 13:02 -0700
            Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-13 16:20 +0000
              Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-13 21:08 +0200
                Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-13 17:30 -0700
                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-14 07:11 +0000
                    Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-14 18:30 -0700
            Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-15 02:46 -0500
            Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-20 14:27 -0700
              Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-20 15:05 -0700
                Re: Given a string, create word with that name (in ANS Forth)? Melzzzzz <Melzzzzz@zzzzz.com> - 2016-09-20 22:19 +0000
              Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-21 12:26 +0000
                Re: Given a string, create word with that name (in ANS Forth)? Coos Haak <htrofhc@gmail.com> - 2016-09-21 15:11 +0200
                  Re: Given a string, create word with that name (in ANS Forth)? mhx@iae.nl - 2016-09-21 10:06 -0700
                    Re: Given a string, create word with that name (in ANS Forth)? Coos Haak <htrofhc@gmail.com> - 2016-09-21 21:12 +0200
                Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-21 12:06 -1000
                  Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-21 15:40 -0700
                    Re: Given a string, create word with that name (in ANS Forth)? "HAA" <someone@microsoft.com> - 2016-09-22 13:04 +1000
                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-22 07:40 +0000
                    Re: Given a string, create word with that name (in ANS Forth)? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-22 15:46 +0100
                      Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-22 11:08 -0700
                      Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-22 22:04 +0200
                        Re: Given a string, create word with that name (in ANS Forth)? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-23 10:21 +0100
                          Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-23 12:06 +0200
                            Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-23 10:44 -0500
                              Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-23 16:26 +0000
                                Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-24 03:46 -0500
                                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-24 10:13 +0000
                                    Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-24 10:34 -0500
                                      Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-24 20:19 +0200
                                        Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-24 09:47 -1000
                                          Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-24 14:29 -0700
                                            Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-24 13:00 -1000
                                              Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-24 16:19 -0700
                                              Re: Given a string, create word with that name (in ANS Forth)? jim.brakefield@ieee.org - 2016-09-24 19:02 -0700
                                                Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-24 21:23 -1000
                                                  Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-25 19:08 -0700
                                                    Re: Given a string, create word with that name (in ANS Forth)? jim.brakefield@ieee.org - 2016-09-25 19:53 -0700
                                                      Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-25 20:00 -0700
                                              Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-25 17:40 -0700
                                            Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-25 01:42 -0500
                                              Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-24 23:45 -0700
                                                Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-25 02:22 -0500
                                                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-26 15:31 +0000
                                                    Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-26 10:42 -0500
                                                      Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-27 15:57 +0000
                                                        Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 19:11 +0200
                                                Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-24 21:28 -1000
                                            Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-25 18:55 -0700
                                          Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-25 09:35 +0200
                                          Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-26 15:38 +0000
                                            Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-26 12:36 -0700
                                      Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-24 20:26 +0200
                                      Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-25 15:22 +0000
                                        Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-25 10:44 -0700
                                          Re: Given a string, create word with that name (in ANS Forth)? Coos Haak <htrofhc@gmail.com> - 2016-09-25 19:55 +0200
                                            Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-25 20:15 +0200
                                              Re: Given a string, create word with that name (in ANS Forth)? Coos Haak <htrofhc@gmail.com> - 2016-09-25 20:26 +0200
                                            Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-25 11:12 -0700
                                              Re: Given a string, create word with that name (in ANS Forth)? Julian Fondren <julian.fondren@gmail.com> - 2016-09-25 11:30 -0700
                                              Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-26 14:51 +0000
                                                Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 14:16 +0200
                            Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-23 07:52 -1000
                        Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-23 10:36 -0500
      Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 13:55 +0200
        Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-12 15:01 +0200
        Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-12 17:29 +0000
          Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 21:02 +0200
            Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-12 13:04 -0700
              Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 22:33 +0200
                Re: Given a string, create word with that name (in ANS Forth)? lawrencedo99@gmail.com - 2016-09-16 18:38 -0700
                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-17 05:33 +0000
                    Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-17 01:40 -0500
                    Re: Given a string, create word with that name (in ANS Forth)? lawrencedo99@gmail.com - 2016-09-16 23:47 -0700
                      Re: Given a string, create word with that name (in ANS Forth)? Julian Fondren <julian.fondren@gmail.com> - 2016-09-17 00:08 -0700
                      Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-17 17:03 +0000
              Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 22:35 +0200
              Re: Given a string, create word with that name (in ANS Forth)? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-09-17 08:16 +0100
    Re: Given a string, create word with that name (in ANS Forth)? Mark Wills <markwills1970@gmail.com> - 2016-09-12 02:49 -0700
      Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 14:04 +0200
      Re: Given a string, create word with that name (in ANS Forth)? Cecil Bayona <cbayona@cbayona.com> - 2016-09-12 09:34 -0500
        Re: Given a string, create word with that name (in ANS Forth)? Mark Wills <markwills1970@gmail.com> - 2016-09-12 08:10 -0700
          Re: Given a string, create word with that name (in ANS Forth)? Cecil Bayona <cbayona@cbayona.com> - 2016-09-12 12:02 -0500
    Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 14:08 +0200

Page 1 of 5  [1] 2 3 4 5  Next page →


#50849 — Given a string, create word with that name (in ANS Forth)?

FromAlex Dowad <alexinbeijing@gmail.com>
Date2016-09-11 06:12 -0700
SubjectGiven a string, create word with that name (in ANS Forth)?
Message-ID<41b6c38e-a2c5-43f9-965b-78f0afdf6ebe@googlegroups.com>
Hello all,

ANS Forth has CREATE, which reads a token from SOURCE and adds a word to the dictionary. But I can't find any word in the standard which takes a string and adds a new word to the dictionary.

This seems to be a failure of orthogonality; CREATE combines the functionality of WORD with that of adding to the dictionary. If those operations were split out from CREATE, that would have provided greater flexibility.

Is there some clever way to get around this, while staying within the standard? Or is it something which can only be done with implementation-specific code?

Thanks, Alex Dowad

[toc] | [next] | [standalone]


#50856

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2016-09-11 10:51 -0500
Message-ID<-ZCdncqJZOYK4EjKnZ2dnUU7-K3NnZ2d@supernews.com>
In reply to#50849
Hi,

Alex Dowad <alexinbeijing@gmail.com> wrote:
> 
> ANS Forth has CREATE, which reads a token from SOURCE and adds a
> word to the dictionary. But I can't find any word in the standard
> which takes a string and adds a new word to the dictionary.

What you need can be written in Standard Forth;

http://git.savannah.gnu.org/cgit/gforth.git/tree/compat/execute-parsing.fs

So you'd use

   ( c-addr u) ' CREATE EXECUTE-PARSING

> Is there some clever way to get around this, while staying within
> the standard?

Yes.

Andrew.

[toc] | [prev] | [next] | [standalone]


#50857

FromAlex Dowad <alexinbeijing@gmail.com>
Date2016-09-11 09:49 -0700
Message-ID<f14f4181-ec0a-4155-85b9-91ba11614789@googlegroups.com>
In reply to#50856
On Sunday, 11 September 2016 17:51:57 UTC+2, Andrew Haley  wrote:
> Hi,
> 
> Alex Dowad <alexinbeijing@gmail.com> wrote:
> > 
> > ANS Forth has CREATE, which reads a token from SOURCE and adds a
> > word to the dictionary. But I can't find any word in the standard
> > which takes a string and adds a new word to the dictionary.
> 
> What you need can be written in Standard Forth;
> 
> http://git.savannah.gnu.org/cgit/gforth.git/tree/compat/execute-parsing.fs
> 
> So you'd use
> 
>    ( c-addr u) ' CREATE EXECUTE-PARSING
> 
> > Is there some clever way to get around this, while staying within
> > the standard?
> 
> Yes.
> 
> Andrew.

OK, I see now: the trick is that EVALUATE temporarily replaces the input source with its string argument.

Thanks!

[toc] | [prev] | [next] | [standalone]


#50859

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2016-09-11 19:57 +0200
Message-ID<86r38ql3ol.fsf@molnjunk.nocrew.org>
In reply to#50856
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
> Alex Dowad <alexinbeijing@gmail.com> wrote:
>> ANS Forth has CREATE, which reads a token from SOURCE and adds a
>> word to the dictionary. But I can't find any word in the standard
>> which takes a string and adds a new word to the dictionary.
>
> What you need can be written in Standard Forth;
> http://git.savannah.gnu.org/cgit/gforth.git/tree/compat/execute-parsing.fs
>
> So you'd use
>    ( c-addr u) ' CREATE EXECUTE-PARSING

I don't think that would work with

   \ Create a word which name is a single space character.
   S"  " ' CREATE EXECUTE-PARSING

[toc] | [prev] | [next] | [standalone]


#50875

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2016-09-12 02:43 -0500
Message-ID<PtKdnXr6EO8NwUvKnZ2dnUU7-b-dnZ2d@supernews.com>
In reply to#50859
Lars Brinkhoff <lars.spam@nocrew.org> wrote:
> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>> Alex Dowad <alexinbeijing@gmail.com> wrote:
>>> ANS Forth has CREATE, which reads a token from SOURCE and adds a
>>> word to the dictionary. But I can't find any word in the standard
>>> which takes a string and adds a new word to the dictionary.
>>
>> What you need can be written in Standard Forth;
>> http://git.savannah.gnu.org/cgit/gforth.git/tree/compat/execute-parsing.fs
>>
>> So you'd use
>>    ( c-addr u) ' CREATE EXECUTE-PARSING
> 
> I don't think that would work with
> 
>   \ Create a word which name is a single space character.
>   S"  " ' CREATE EXECUTE-PARSING

I'm glad to hear that.

Andrew.

[toc] | [prev] | [next] | [standalone]


#50863

FromPaul Rubin <no.email@nospam.invalid>
Date2016-09-11 14:31 -0700
Message-ID<87wpiigm3f.fsf@jester.gateway.pace.com>
In reply to#50856
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
> http://git.savannah.gnu.org/cgit/gforth.git/tree/compat/execute-parsing.fs
> So you'd use
>    ( c-addr u) ' CREATE EXECUTE-PARSING

I remember thinking that implemention was very clever but it would be
nicer if Forth included the functionality directly.  A lot of the
machinery in Forth seems to be there for the sake of implementing Forth
itself, so various small gaps like that call out for being filled.

[toc] | [prev] | [next] | [standalone]


#50858

Fromhughaguilar96@gmail.com
Date2016-09-11 10:14 -0700
Message-ID<5212f07b-1adf-4510-a944-ec2be487eb37@googlegroups.com>
In reply to#50849
On Sunday, September 11, 2016 at 6:12:40 AM UTC-7, Alex Dowad wrote:
> Hello all,
> 
> ANS Forth has CREATE, which reads a token from SOURCE and adds a word to the dictionary. But I can't find any word in the standard which takes a string and adds a new word to the dictionary.
> 
> This seems to be a failure of orthogonality; CREATE combines the functionality of WORD with that of adding to the dictionary. If those operations were split out from CREATE, that would have provided greater flexibility.
> 
> Is there some clever way to get around this, while staying within the standard? Or is it something which can only be done with implementation-specific code?
> 
> Thanks, Alex Dowad

I have :NAME in the novice-package which is written in ANS-Forth. I tried to get this put into Forth-200x but my RfD was shot down --- that was way back in 2009 before I realized that everything in Forth-200x has to come from the committee and they aren't interested in input from Forth programmers.

It uses EVALUATE, so it is constructing source-code with colon and then colon is calling something very similar to :NAME internally --- I wouldn't call this "clever" --- better words would be "ugly" or "over-complicated" or "inefficient" etc..

[toc] | [prev] | [next] | [standalone]


#50876

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-09-12 07:46 +0000
Message-ID<2016Sep12.094616@mips.complang.tuwien.ac.at>
In reply to#50849
Alex Dowad <alexinbeijing@gmail.com> writes:
>ANS Forth has CREATE, which reads a token from SOURCE and adds a word to the dictionary. But I can't find any word in the standard which takes a string and adds a new word to the dictionary.
>
>This seems to be a failure of orthogonality; CREATE combines the functionality of WORD with that of adding to the dictionary. If those operations were split out from CREATE, that would have provided greater flexibility.

Yes.

>Is there some clever way to get around this, while staying within the standard? Or is it something which can only be done with implementation-specific code?

As others have pointer out, EXECUTE-PARSING will do it, and there is a
standard implementation of it; the releases are found in the compat
library: <http://theforth.net/package/compat>.

Concerning defining words with names that cannot be provided by
PARSE-NAME, such as a string containing a space: I don't that that can
be done with the current standard, because the standard CREATE parses
the name in the same way as PARSE-NAME (and typically it calls
PARSE-NAME or WORD); however, Gforth provides NEXTNAME ( c-addr u -- ),
and you can CREATE a word with a space as a name as follows:

s"  " nextname create

- 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/

[toc] | [prev] | [next] | [standalone]


#50877

FromPaul Rubin <no.email@nospam.invalid>
Date2016-09-12 01:10 -0700
Message-ID<87fup5h738.fsf@jester.gateway.pace.com>
In reply to#50876
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> Gforth provides NEXTNAME ( c-addr u -- ),
> and you can CREATE a word with a space as a name as follows:
> s"  " nextname create

This is nice.  I didn't know about it.  Any chance of proposing
standardizing it?

[toc] | [prev] | [next] | [standalone]


#50878

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-09-12 09:01 +0000
Message-ID<2016Sep12.110144@mips.complang.tuwien.ac.at>
In reply to#50877
Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> Gforth provides NEXTNAME ( c-addr u -- ),
>> and you can CREATE a word with a space as a name as follows:
>> s"  " nextname create
>
>This is nice.  I didn't know about it.  Any chance of proposing
>standardizing it?

Nobody is going to stop you from proposing it.  Whether it is accepted
by the committee is doubtful, but occasional surprises have happened.
Questions that might be asked are: How much common practice is there?
And is EXECUTE-PARSING not a better approach to the same problem?  If
not, why not?

- 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/

[toc] | [prev] | [next] | [standalone]


#50890

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-12 14:02 +0200
Message-ID<nr65g0$jen$1@cherry.spenarnc.xs4all.nl>
In reply to#50878
In article <2016Sep12.110144@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>Paul Rubin <no.email@nospam.invalid> writes:
>>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>> Gforth provides NEXTNAME ( c-addr u -- ),
>>> and you can CREATE a word with a space as a name as follows:
>>> s"  " nextname create
>>
>>This is nice.  I didn't know about it.  Any chance of proposing
>>standardizing it?
>
>Nobody is going to stop you from proposing it.  Whether it is accepted
>by the committee is doubtful, but occasional surprises have happened.
>Questions that might be asked are: How much common practice is there?
>And is EXECUTE-PARSING not a better approach to the same problem?  If
>not, why not?

The tradition that all new dictionary entries have a name that
is parsed from the input stream is one of the things that holds
Forth back.

The proper design solution is to have name-tokens (and that we want to
change the name of a name token proves that name token is not a good
name) or dea. Then a means to fill in the name of the dea.
Orthogonal, understandable, solid.
It would look like (with a denotation for strings and dea's):
"ape" 'something NAME!

dea : dictionary entry address

>- anton

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

[toc] | [prev] | [next] | [standalone]


#51123

From"HAA" <someone@microsoft.com>
Date2016-09-20 12:06 +1000
Message-ID<nrq5hs$19n1$1@gioia.aioe.org>
In reply to#50890
Albert van der Horst wrote:
> ...
> The tradition that all new dictionary entries have a name that
> is parsed from the input stream is one of the things that holds
> Forth back.

I haven't noticed.  What I have noticed is the ease with which Forth can
be messed with and the willingness of c.l.f.'ers to be distracted.

> ...
> I looked up the implementation of it in ciforth:
> : EXECUTE-PARSING SAVE SET-SRC CATCH RESTORE THROW ; \ ISO
>
> Doesn't look overly complicated to me. Of course use must be
> made of factors that already exist, not an attempt to
> do something supposedly portable.

I would call this function FEED.  While I could modify my system to provide it,
I would then feel the need to justify it by finding uses for a function I've not yet
needed.  Should the day come when I do need it, a temporary definition will do e.g.

: +STRING ( a1 u1 a2 u2 -- a2 u3)
  2swap swap 2over + 2 pick cmove + ;

: FEED ( a u xt -- )
  -rot s" EXECUTE " pad 0 +string +string evaluate ;

It doesn't have to be idiot-proof and the syntax may vary between applications.
Whatever is simplest for the task at hand.

> ...
> (I've seen a habit of uppercasing words where they are defined.
> Blech.)

Works for me.  A definition name in uppercase means it's intended
for the end-user.  A lowercase definition name means it's a factor or
component not for general use.  While the system is case-insensitive,
names in the dictionary appear in the case defined.


[toc] | [prev] | [next] | [standalone]


#51127

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-20 11:27 +0200
Message-ID<nrqvdd$ean$1@cherry.spenarnc.xs4all.nl>
In reply to#51123
In article <nrq5hs$19n1$1@gioia.aioe.org>, HAA <someone@microsoft.com> wrote:
>Albert van der Horst wrote:
>> ...
>> The tradition that all new dictionary entries have a name that
>> is parsed from the input stream is one of the things that holds
>> Forth back.
>
>I haven't noticed.  What I have noticed is the ease with which Forth can
>be messed with and the willingness of c.l.f.'ers to be distracted.

That is on a different level.

>
>> ...
>> I looked up the implementation of it in ciforth:
>> : EXECUTE-PARSING SAVE SET-SRC CATCH RESTORE THROW ; \ ISO
>>
>> Doesn't look overly complicated to me. Of course use must be
>> made of factors that already exist, not an attempt to
>> do something supposedly portable.
>
>I would call this function FEED.  While I could modify my system to provide it,
>I would then feel the need to justify it by finding uses for a function I've not yet
>needed.  Should the day come when I do need it, a temporary definition will do e.g.
>
>: +STRING ( a1 u1 a2 u2 -- a2 u3)
>  2swap swap 2over + 2 pick cmove + ;
>
>: FEED ( a u xt -- )
>  -rot s" EXECUTE " pad 0 +string +string evaluate ;
>
>It doesn't have to be idiot-proof and the syntax may vary between applications.
>Whatever is simplest for the task at hand.

EXECUTE-PARSING is not my invention. I just demonstrated that I can
implement it.

FEED is a much better name !!!

>
>> ...
>> (I've seen a habit of uppercasing words where they are defined.
>> Blech.)
>
>Works for me.  A definition name in uppercase means it's intended
>for the end-user.  A lowercase definition name means it's a factor or
>component not for general use.  While the system is case-insensitive,
>names in the dictionary appear in the case defined.

uppercasing words where they are defined means this:

: DROP xxx yyy zzz ;
: TEST blabla drop blabla DROP ;

So the case is different where they are defined (didn't I say that
already).

Anyway what you say are fine examples of putting the case to good use.
I hate case-insensitivity, like the first Chinese person.
It is okay temporarily while testing to reduce typo's.

Groetjes Albert
>
>
>
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

[toc] | [prev] | [next] | [standalone]


#50908

FromPaul Rubin <no.email@nospam.invalid>
Date2016-09-12 13:02 -0700
Message-ID<87bmzshoow.fsf@jester.gateway.pace.com>
In reply to#50878
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>> Gforth provides NEXTNAME ( c-addr u -- ),
>>Any chance of proposing standardizing it?
> Nobody is going to stop you from proposing it.  Whether it is accepted
> by the committee is doubtful

OK, that's basically what I was asking.  You're saying that such a
proposal is unlikely to be successful.  That's a sufficient answer.
Thanks.

> Questions that might be asked are: How much common practice is there?

It seems to me like many Forths must already have a mechanism like that
under the covers somewhere.

> And is EXECUTE-PARSING not a better approach to the same problem?  If
> not, why not?

The implementation I looked at seemed painfully complicated.

[toc] | [prev] | [next] | [standalone]


#50939

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-09-13 16:20 +0000
Message-ID<2016Sep13.182043@mips.complang.tuwien.ac.at>
In reply to#50908
Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> And is EXECUTE-PARSING not a better approach to the same problem?  If
>> not, why not?
>
>The implementation I looked at seemed painfully complicated.

It's a bit less complicated than EVALUATE, and can be used as factor
of EVALUATE.

EXECUTE-PARSING is certainly more complicated to implement than
NEXTNAME, but as you need these complications anyway to implement
EVALUATE, the additional cost of providing EXECUTE-PARSING is smaller;
also, it works for all parsing words, while NEXTNAME only works for
defining words.

- 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/

[toc] | [prev] | [next] | [standalone]


#50948

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-13 21:08 +0200
Message-ID<nr9irh$it$1@cherry.spenarnc.xs4all.nl>
In reply to#50939
In article <2016Sep13.182043@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>Paul Rubin <no.email@nospam.invalid> writes:
>>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>> And is EXECUTE-PARSING not a better approach to the same problem?  If
>>> not, why not?
>>
>>The implementation I looked at seemed painfully complicated.
>
>It's a bit less complicated than EVALUATE, and can be used as factor
>of EVALUATE.
>
>EXECUTE-PARSING is certainly more complicated to implement than
>NEXTNAME, but as you need these complications anyway to implement
>EVALUATE, the additional cost of providing EXECUTE-PARSING is smaller;
>also, it works for all parsing words, while NEXTNAME only works for
>defining words.

I looked up the implementation of it in ciforth:
: EXECUTE-PARSING SAVE SET-SRC CATCH RESTORE THROW ; \ ISO

Doesn't look overly complicated to me. Of course use must be
made of factors that already exist, not an attempt to
do something supposedly portable.

In my opinion NEXTNAME is inherently more complicated
because it links the input stream and header construction.

>
>- anton

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

[toc] | [prev] | [next] | [standalone]


#50953

FromPaul Rubin <no.email@nospam.invalid>
Date2016-09-13 17:30 -0700
Message-ID<87intze31m.fsf@jester.gateway.pace.com>
In reply to#50948
albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes:
> I looked up the implementation of it in ciforth:
> : EXECUTE-PARSING SAVE SET-SRC CATCH RESTORE THROW ; \ ISO

Is that an ANS implementation when you count all the factors?  The one
with gforth is ANS, but much more complicated.

[toc] | [prev] | [next] | [standalone]


#50956

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-09-14 07:11 +0000
Message-ID<2016Sep14.091155@mips.complang.tuwien.ac.at>
In reply to#50953
Paul Rubin <no.email@nospam.invalid> writes:
>albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes:
>> I looked up the implementation of it in ciforth:
>> : EXECUTE-PARSING SAVE SET-SRC CATCH RESTORE THROW ; \ ISO
>
>Is that an ANS implementation when you count all the factors?  The one
>with gforth is ANS, but much more complicated.

I guess you mean the compat-library implementation
<http://git.savannah.gnu.org/cgit/gforth.git/tree/compat/execute-parsing.fs>

That's complicated because it limits itself to the standard, and the
standard does not provide a direct way to implement it, so it has to
be implemented in a very roundabout way, as demonstrated by the fact
that it took 4 years (from 2000, when Jenny Brien invented
EXECUTE-PARSING <8s7mkl$4ql$1@news6.svr.pol.co.uk>, until 2004
<2004Aug31.152104@mips.complang.tuwien.ac.at>) to find an
implementation in standard Forth.

There is a direct, non-standard implementation in Gforth:

: execute-parsing ( ... addr u xt -- ... ) \ gforth
\G Make @i{addr u} the current input source, execute @i{xt @code{(
\G ... -- ... )}}, then restore the previous input source.
    s" *evaluated string*" execute-parsing-wrapper ;

(EXECUTE-PARSING-WRAPPER is however, not nice to look at.)

- 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/

[toc] | [prev] | [next] | [standalone]


#50981

Fromhughaguilar96@gmail.com
Date2016-09-14 18:30 -0700
Message-ID<6ef350ef-cff6-4696-865c-35642ddf905c@googlegroups.com>
In reply to#50956
On Wednesday, September 14, 2016 at 12:33:01 AM UTC-7, Anton Ertl wrote:
> Paul Rubin <no.email@nospam.invalid> writes:
> >albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes:
> >> I looked up the implementation of it in ciforth:
> >> : EXECUTE-PARSING SAVE SET-SRC CATCH RESTORE THROW ; \ ISO
> >
> >Is that an ANS implementation when you count all the factors?  The one
> >with gforth is ANS, but much more complicated.
> 
> I guess you mean the compat-library implementation
> <http://git.savannah.gnu.org/cgit/gforth.git/tree/compat/execute-parsing.fs>
> 
> That's complicated because it limits itself to the standard, and the
> standard does not provide a direct way to implement it, so it has to
> be implemented in a very roundabout way, as demonstrated by the fact
> that it took 4 years (from 2000, when Jenny Brien invented
> EXECUTE-PARSING <8s7mkl$4ql$1@news6.svr.pol.co.uk>, until 2004
> <2004Aug31.152104@mips.complang.tuwien.ac.at>) to find an
> implementation in standard Forth.

4 years???

Implementing :NAME in ANS-Forth was trivial --- that took me about one day --- after that, I was able to use it extensively throughout the novice-package.

[toc] | [prev] | [next] | [standalone]


#50996

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2016-09-15 02:46 -0500
Message-ID<y-ydnX6gwe1ZzEfKnZ2dnUU7-YednZ2d@supernews.com>
In reply to#50908
Paul Rubin <no.email@nospam.invalid> wrote:
> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> 
>> And is EXECUTE-PARSING not a better approach to the same problem?  If
>> not, why not?
> 
> The implementation I looked at seemed painfully complicated.

It is, but that's because it has to cover a bunch of corner cases in a
standard-compliant way.  I think an implementation which used system
internals could be simpler.  EXECUTE-PARSING is a good idea; I only
hate its name.  No, I have not come up with a better one!

Andrew.

[toc] | [prev] | [next] | [standalone]


Page 1 of 5  [1] 2 3 4 5  Next page →

Back to top | Article view | comp.lang.forth


csiph-web