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


Groups > comp.lang.forth > #60785

Re: Another recognizer discussion

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Another recognizer discussion
Date 2017-06-15 16:19 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2017Jun15.181935@mips.complang.tuwien.ac.at> (permalink)
References (6 earlier) <4v2dnYUzuLdLgazEnZ2dnUU7-RfNnZ2d@supernews.com> <2017Jun10.182826@mips.complang.tuwien.ac.at> <593d1a33.325401143@news.eternal-september.org> <2017Jun13.160403@mips.complang.tuwien.ac.at> <5941223c.589602455@news.eternal-september.org>

Show all headers | View raw


stephen@mpeforth.com (Stephen Pelc) writes:
stephen@mpeforth.com (Stephen Pelc) writes:
>On Tue, 13 Jun 2017 14:04:03 GMT, anton@mips.complang.tuwien.ac.at
>(Anton Ertl) wrote:
>
>>stephen@mpeforth.com (Stephen Pelc) writes:
>>>On Sat, 10 Jun 2017 16:28:26 GMT, anton@mips.complang.tuwien.ac.at
>>>(Anton Ertl) wrote:
>>>>The xt still does not represent interpretation and compilation
>>>>semantics; you still need to know the immediacy of the word in order
>>>>to perform its compilation semantics.
>>>
>>>The xt should be the single point of reference to a word.
>>
>>Not in ANS Forth.
>>
>>>If you
>>>cannot determine immediacy from it, the implementation is broken.
>
>A Forth system is much more than its compliance to a standard. The
>base problem is that the standard describes words in terms that
>cannot be implemented or explored in a standard way. In particular,
>we have no way to explore separate interpretation and compilation
>actions - the ones with non-default compilation semantics. Once
>we fix that, all the hassle of STATE-smart words goes away because
>we have tools to implement equivalent behaviour in a standard way
>that works with POSTPONE. Until we can do that, people will
>write STATE-smart words because there is no alternative. The
>standard needs to provide an alternative.

So what you mean here is that we need a standard way to define words
with arbitrary combinations of interpretation and compilation
semantics.  Gforth has had the following for about two decades:

interpret/compile: ( interp-xt comp-xt "name" –- )

A simple example of that is:

:noname ' defer@ ;
:noname  postpone ['] postpone defer@ ;
interpret/compile: action-of ( interpretation "name" -- xt;
                             ( compilation "name" -- ; 
                             (   run-time -- xt )

>>Not in ANS Forth nor in Forth-2012.  There is no word in these
>>standards for getting the immediacy out of the xt.  And immediacy is
>>inadequate for specifying words like S", anyway; for that we need to
>>determine interpretation semantics and compilation semantics.  And in
>>Forth-2012, we have words for getting at those: NAME>INTERPRET and
>>NAME>COMPILE.
>
>That's not enough

It's enough to get interpretation and compilation semantics, i.e.,
what we are discussing here.  But if you are missing functionality,
please let me know what it is.  

>and is biased to NT-centric systems.

Just because it does not exclude (what you call) NT-centric systems
does not mean it's biased to them.  On a system where you can get at
everything from the xt, you should have no problem implementing these
words; and looking at VFX, you have implemented them already.

>>Among Gforth, iForth, SwiftForth, and VFX, only VFX and Gforth have
>>"IMMEDIATE?", and in Gforth the stack effect of IMMEDIATE? is ( nt --
>>flag ). And at least in Gforth, immediacy is associated with the name,
>>not with the xt; and thanks to SYNONYM and ALIAS, the same xt can have
>>multiple names, and these names can have different immediacies:
>
>Gforth should let NTs be the point of contact with a word and then you
>can call them XTs. All you need is a dummy header for immediate
>:NONAMEs.

Actually, in the development version of Gforth, the nt and xt of many
words is the same:

s" +" find-name cr . ' + cr . 
140309735259024 
140309735259024  ok

And in this version you can apply the NAME>... words to xts and you
will get a valid result (but not necessarily the one *you* expect):

:noname ; cr dup . name>string cr . .               
140309735823352 
0 140309735823328  ok

So a :NONAME word has a 0-length string as name.

And as long as we live in the simple world of simple Forth
definitions, you can use xts and nts interchangeably in the
development version of Gforth.

But once you get into stuff like SYNONYMS and INTERPRET/COMPILE:
words, you no longer have a 1:1 relation between nts and xts, and this
shows up in getting different xts from nts for the same word, and when
you (try to perform) xt operations on nts and vice versa:

: foo ." foo" ;  ok
synonym bar foo  ok
' foo cr . ' bar cr . s" foo" find-name cr . s" bar" find-name cr . 
140309735823416 
140309735823416 
140309735823416 
140309735823560  ok

s" foo" find-name execute foo ok
s" bar" find-name execute 
*the terminal*:13: error: Invalid memory address
s" bar" find-name >>>execute<<<

' foo name>string type foo ok
' bar name>string type foo ok

: flip ." flip" ;  ok
: flop ." flop" ;  ok
' flip ' flop interpret/compile: flipflop  ok
flipflop flip ok
: test flipflop ; flop ok

' flip cr . ' flipflop cr . ' flop cr . s" flipflop" find-name cr . 
139666024978584 
139666024978584 
139666024978728 
139666024978872  ok

' flipflop name>string type flip ok

s" flipflop" find-name execute 
*the terminal*:17: error: Invalid memory address

s" flipflop" find-name name>compile cr . cr . ' flop cr . 
139666024411520 
139666024978728 
139666024978728  ok

s" flipflop" find-name name>compile cr name>string type cr name>string type 
execute
flop ok

As you can see here, even in a system that tries to have xt=nt, there
is a difference in a number of cases.  One might implement a nicer
behaviour in those cases where EXECUTEing an nt produces an "Invalid
memory address" exception (at a cost in complexity), but the other
cases are a natural consequence of the requirements.

>And how about :NONAMEs with separate interpretation and compilation
>behaviour?

You can create such a word in development Gforth with

' flip ' flop noname interpret/compile:

However, at the moment there is no good way to get at the nt nor any
of the xts of this word.

But anyway, what's the point of such a word?  Interpretation semantics
and compilation semantics are there for text interpretation of a word,
but without a name you cannot use it directly in text interpretation
(nor in POSTPONE or ').

>The issue here is that we need to set the language philosophy and
>design (as expressed in the standard) rather than to focus on corner
>cases.

A design that does not work in corner cases is a mis-design.

>The big trouble with NTs is that they were introduced to
>fix a problem in TRAVERSE-WORDLIST before any consequences were 
>discussed. Now NTs are opeing the fig-Forth can of worms again.

We discussed the consequences at the time and you expressed that
concern at the time, very insistently, but you were eventually
convinced that NTs are necessary.

NTs are necessary because of features that fig-Forth does not have,
and therefore have nothing to do with fig-Forth.  These features are
SYNONYMs, separate headers, and INTERPRET/COMPILE:.  If we remove all
these features from our Forth systems, then yes, there will be a 1:1
relation between NTs and XTs, and we can unify these two concepts.
Note that in the Gforth examples above, the xt<>nt cases are those
where the features mentioned above come into play (except separate
headers; we don't have that in Gforth).

>>> In modern systems you also need
>>>NDCS? (Non-Default Compilation Semantics) to deal with what 
>>>the standard permits.
>>
>>We already have NAME>COMPILE, no NDCS? or IMMEDIATE? necessary.  How
>>would you use "NDCS?"?
>
>You invented it! You reminded me that words such as IF may return
>values at compile time so cannot be compiled with COMPILE, - in
>other words they have to be IMMEDIATE. Similarly words such as
>S" parse at compile time, so so have non-default compilation
>semantics. We have no standard tools to implement words with
>Non-Default Compilation Semantics and we need them.

Maybe we need INTERPRET/COMPILE:, but that still does not tell me how
you would use "NDCS?"; and I certainly did not invent "NDCS?".  As far
as I can tell, you did.

- 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 2017: http://www.euroforth.org/ef17/

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Another recognizer discussion Alex <alex@rivadpm.com> - 2017-05-29 20:47 +0100
  Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-05-29 20:57 +0100
    Re: Another recognizer discussion peter.m.falth@gmail.com - 2017-05-29 13:18 -0700
      Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-05-29 22:47 +0100
      Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-30 07:43 +0000
    Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-30 07:30 +0000
    Re: Another recognizer discussion albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-30 09:53 +0200
    Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-05-30 22:02 +0100
      Re: Another recognizer discussion peter.m.falth@gmail.com - 2017-05-31 01:27 -0700
        Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-05-31 15:12 +0100
      Re: Another recognizer discussion minforth@arcor.de - 2017-05-31 03:43 -0700
        Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-05-31 15:03 +0100
        Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-31 16:46 +0000
      Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-31 11:28 +0000
        Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-31 12:17 +0000
        Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-05-31 15:10 +0100
          Re: Another recognizer discussion mhx@iae.nl - 2017-05-31 11:01 -0700
          Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-05-31 22:55 +0000
            Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-01 05:50 +0000
              Re: Another recognizer discussion minforth@arcor.de - 2017-05-31 23:57 -0700
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-01 09:08 +0000
                Re: Another recognizer discussion minforth@arcor.de - 2017-06-01 03:33 -0700
              Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-01 09:05 +0000
                Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-06-01 15:05 +0100
                Re: Another recognizer discussion Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-06-01 10:05 -0500
                Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-06-01 16:32 +0100
                Re: Another recognizer discussion Brad Eckert <hwfwguy@gmail.com> - 2017-06-01 09:31 -0700
                Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-06-01 19:00 +0100
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-04 22:56 +0000
                Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-06-05 14:41 +0100
                Re: Another recognizer discussion Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-06-02 03:07 -0500
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-10 16:28 +0000
                Re: Another recognizer discussion Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-06-11 02:14 -0500
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-11 10:55 +0000
                Re: Another recognizer discussion Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-06-12 03:22 -0500
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-13 15:21 +0000
                Re: Another recognizer discussion Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-06-14 04:10 -0500
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-15 10:43 +0000
                Re: Another recognizer discussion Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-06-15 09:11 -0500
                Re: Another recognizer discussion minforth@arcor.de - 2017-06-14 02:55 -0700
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-14 10:19 +0000
                Re: Another recognizer discussion minforth@arcor.de - 2017-06-14 05:44 -0700
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-14 14:27 +0000
                Re: Another recognizer discussion minforth@arcor.de - 2017-06-14 08:06 -0700
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-14 16:36 +0000
                Re: Another recognizer discussion Brad Eckert <hwfwguy@gmail.com> - 2017-06-15 09:48 -0700
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-15 17:18 +0000
                Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-06-15 18:50 +0100
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-15 19:22 +0000
                Re: Another recognizer discussion minforth@arcor.de - 2017-06-15 13:09 -0700
                Re: Another recognizer discussion Brad Eckert <hwfwguy@gmail.com> - 2017-06-15 13:43 -0700
                Re: Another recognizer discussion Lars Brinkhoff <lars.spam@nocrew.org> - 2017-06-15 22:55 +0200
                Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-06-15 22:20 +0100
                pre-Rfd for smart word definition mechanism (was: Another ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-16 17:04 +0000
                Re: pre-Rfd for smart word definition mechanism (was: Another ...) stephen@mpeforth.com (Stephen Pelc) - 2017-06-16 21:58 +0000
                Re: pre-Rfd for smart word definition mechanism (was: Another ...) JennyB <jennybrien@googlemail.com> - 2017-06-17 00:26 -0700
                Re: pre-Rfd for smart word definition mechanism (was: Another ...) minforth@arcor.de - 2017-06-17 01:18 -0700
                Re: pre-Rfd for smart word definition mechanism (was: Another ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-17 15:24 +0000
                Re: pre-Rfd for smart word definition mechanism (was: Another ...) JennyB <jennybrien@googlemail.com> - 2017-06-17 12:29 -0700
                Re: pre-Rfd for smart word definition mechanism (was: Another ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-18 12:29 +0000
                Re: pre-Rfd for smart word definition mechanism (was: Another ...) albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-06-18 16:47 +0200
                Re: pre-Rfd for smart word definition mechanism (was: Another ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-17 10:20 +0000
                Re: Another recognizer discussion Brad Eckert <hwfwguy@gmail.com> - 2017-06-15 13:01 -0700
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-16 16:55 +0000
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-16 17:40 +0000
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-16 16:47 +0000
                Re: Another recognizer discussion Brad Eckert <hwfwguy@gmail.com> - 2017-06-15 10:34 -0700
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-17 17:35 +0000
                Re: Another recognizer discussion peter.m.falth@gmail.com - 2017-06-17 15:24 -0700
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-18 12:00 +0000
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-16 12:29 +0000
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-16 07:35 +0000
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-11 10:39 +0000
                Re: Another recognizer discussion Richard Owlett <rowlett@cloud85.net> - 2017-06-11 07:19 -0500
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-13 14:04 +0000
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-14 12:50 +0000
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-15 16:19 +0000
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-02 07:59 +0000
                Re: Another recognizer discussion Lars Brinkhoff <lars.spam@nocrew.org> - 2017-06-02 11:48 +0200
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-02 10:24 +0000
                Re: Another recognizer discussion Lars Brinkhoff <lars.spam@nocrew.org> - 2017-06-02 13:04 +0200
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-02 13:30 +0000
                Re: Another recognizer discussion Lars Brinkhoff <lars.spam@nocrew.org> - 2017-06-02 16:36 +0200
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-02 15:51 +0000
                Re: Another recognizer discussion Lars Brinkhoff <lars.spam@nocrew.org> - 2017-06-02 21:09 +0200
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-01 15:55 +0000
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-01 14:21 +0000
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-04 23:07 +0000
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-10 15:49 +0000
                Re: Another recognizer discussion stephen@mpeforth.com (Stephen Pelc) - 2017-06-11 11:14 +0000
                Re: Another recognizer discussion minforth@arcor.de - 2017-06-11 08:24 -0700
                Re: Another recognizer discussion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-13 15:07 +0000
            Re: Another recognizer discussion Alex <alex@rivadpm.com> - 2017-06-01 12:11 +0100
  Re: Another recognizer discussion Matthias Trute <matthias.trute@gmail.com> - 2017-05-30 11:03 -0700

csiph-web