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


Groups > comp.lang.forth > #56473

Re: bug in VFX --- IF does't work

From Bernd Paysan <bernd@net2o.de>
Newsgroups comp.lang.forth
Subject Re: bug in VFX --- IF does't work
Date 2017-03-30 02:55 +0000
Organization A noiseless patient Spider
Message-ID <obhs3b$mq9$2@dont-email.me> (permalink)
References (2 earlier) <c73bb02b-badf-4da0-968f-2068da15314b@googlegroups.com> <oak95d$sr4$1@dont-email.me> <2017Mar19.115341@mips.complang.tuwien.ac.at> <oauvh5$5f5$1@dont-email.me> <2017Mar23.132339@mips.complang.tuwien.ac.at>

Show all headers | View raw


Am Thu, 23 Mar 2017 12:23:39 +0000 schrieb Anton Ertl:
> As an example, let's turn IF into a deferred word:
> 
>   ' if defer if immediate is if
> 
> [Ok, you might argue that a standard program cannot ' IF; in that case,
> use FIND instead; and is that stance really compatible with the "xt as
> universal token" dogma?]

Here is where your argument already breaks.  We don't know what ' IF 
returns as xt, because that is left to the implementer - deliberately.  
We know what IF does when it is encountered by the text interpreter in 
compilation state.  You can know if you use FIND and check if it is 
immediate or not.  So if it is immediate, you can bind it with IS IF to 
the new deferred IF.  If it is non-immediate, you can't, so you probably 
need to define

: IF  postpone IF ; immediate

first to get a reliable immediate IF, and then create the deferred IF.

When you don't know what IF is, you can't tick it (and expect some 
meaningful xt as result), and therefore, your program is non-standard and 
will break in various ways depending on what's different between your 
assumption and the actual system.  There is simply no place in the 
standard that says IF must be immediate, and that is on purpose.

"xt as universal token" doesn't work well on systems with immediate 
words, because the xt alone doesn't contain the information about 
immediacy.

The "xt as universal token" doctrine only works on a system without 
immediacy at all, i.e. all compilation macro stuff is done through 
COMPILE,.

> Nor would they have.  Not everything that some system implementor
> considers a good idea actually is.  We see ample demonstration of this
> in the way gcc deals with "undefined behaviour", but the way that VFX
> defines IF in connection with EXECUTE and COMPILE, is another example.

The ANS Forth standard came into existence by making a survey what people 
did and tried to figure out how to write the standard in a way that made 
these different approaches fit.

We of course can't know exactly what they would have, but judging from 
the Forth 200x effort, we try to bend over backwards to make sure even 
systems where one particular vendor did things all others think are 
stupid (like using curly brackets for multi-line comments when everybody 
else was using them for locals with a sane order), they certainly would 
have made it possible for VFX to be standard.

The complexity of words with different interpretation and compilation 
semantics can be shifted around, and of course, it will never completely 
go away.  Each solution has its drawbacks and advantages.  "My solution 
is the only one" is not the way a standard that tries to build on common 
practice works.

Red herrings in a discussion don't help.  If the example already requires 
carnal knowledge, it is a non-standard program, and therefore doesn't 
need to work on every system.

We already went through that discussion.  The result was:

1. Words with default compilation semantics are no problem.

2. Words with only compilation semantics and no interpretation semantics 
can't be ticked meaningfully, because the user can't know whether they 
are immediate or not - using FIND gives you that answer, but you need to 
take it into account when you use that xt.  Your examples don't, and ANS 
Forth already said it will fail.

3. Words with both interpretation and compilation semantics, and we agree 
that they have the same problems as the second class, and therefore we 
also don't allow to ' them in a standard program (results are not 
reproducible across systems, this is not meaningful).  Here, we needed to 
fix the standard, as ANS Forth did not say "here be dragons" with S".

4. User-defined word with non-default compilation semantics.  And this is 
not a problem, because the user knows how he did it, and what caveats 
that approach has.  This is reproducible.  If it's not the expected 
behavior, the user will do something about it.

From a "avoid confusion" point of view, I'm for reducing the options.  
Now, in development Gforth, the user has three possibilities to define a 
word with non-default compilation semantics: state-smart, using set-
optimize, and dual-xt with interpret/compile: or set-comp.  For typical 
use, the user won't see a difference, as it's all fringe cases where you 
actually see the difference.  You need to ' it, you need to start 
POSTPONE or COMPILE, it.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
http://bernd-paysan.de/

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


Thread

Re: bug in VFX --- IF does't work rickman <gnuarm@gmail.com> - 2017-03-18 17:37 -0400
  Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-18 15:08 -0700
  Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-18 15:17 -0700
    Re: bug in VFX --- IF does't work Alex <alex@rivadpm.com> - 2017-03-18 22:22 +0000
      Re: bug in VFX --- IF does't work rickman <gnuarm@gmail.com> - 2017-03-18 19:47 -0400
        Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-18 17:06 -0700
          Re: bug in VFX --- IF does't work rickman <gnuarm@gmail.com> - 2017-03-18 20:58 -0400
          Re: bug in VFX --- IF does't work Alex <alex@rivadpm.com> - 2017-03-19 18:04 +0000
  Re: bug in VFX --- IF does't work anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-19 10:53 +0000
    Re: bug in VFX --- IF does't work Cecil Bayona <cbayona@cbayona.com> - 2017-03-19 12:57 -0500
      Re: bug in VFX --- IF does't work Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-19 13:39 -0500
      Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-19 14:48 -0700
        Re: bug in VFX --- IF does't work Alex <alex@rivadpm.com> - 2017-03-19 22:05 +0000
    Re: bug in VFX --- IF does't work Alex <alex@rivadpm.com> - 2017-03-19 17:57 +0000
    Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-19 12:18 -0700
    Re: bug in VFX --- IF does't work Bernd Paysan <bernd@net2o.de> - 2017-03-22 22:57 +0000
      Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-22 17:18 -0700
      Re: bug in VFX --- IF does't work Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-23 04:03 -0500
        Re: bug in VFX --- IF does't work albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-03-23 15:01 +0100
          Re: bug in VFX --- IF does't work peter.m.falth@gmail.com - 2017-03-23 07:12 -0700
            Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-29 20:31 -0700
          Re: bug in VFX --- IF does't work Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-23 10:22 -0500
            Re: bug in VFX --- IF does't work Bernd Paysan <bernd@net2o.de> - 2017-03-30 02:31 +0000
              Re: bug in VFX --- IF does't work Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-30 03:36 -0500
                Re: bug in VFX --- IF does't work anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-30 15:45 +0000
                Re: bug in VFX --- IF does't work Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-30 12:03 -0500
                Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-30 14:04 -0700
                Re: bug in VFX --- IF does't work anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-31 09:23 +0000
                Re: bug in VFX --- IF does't work Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-31 07:43 -0500
                Re: bug in VFX --- IF does't work anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-01 12:55 +0000
                Re: bug in VFX --- IF does't work Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-04-01 11:52 -0500
      Re: bug in VFX --- IF does't work anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-23 12:23 +0000
        Re: bug in VFX --- IF does't work Alex <alex@rivadpm.com> - 2017-03-23 15:57 +0000
          Re: bug in VFX --- IF does't work anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-23 17:38 +0000
            Re: bug in VFX --- IF does't work Alex <alex@rivadpm.com> - 2017-03-23 17:58 +0000
              Re: bug in VFX --- IF does't work Alex <alex@rivadpm.com> - 2017-03-23 19:16 +0000
              Re: bug in VFX --- IF does't work anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-24 09:52 +0000
        Re: bug in VFX --- IF does't work anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-23 18:26 +0000
        Re: bug in VFX --- IF does't work Bernd Paysan <bernd@net2o.de> - 2017-03-30 02:55 +0000
          Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-29 20:49 -0700
          Re: bug in VFX --- IF does't work Mark Wills <markwills1970@gmail.com> - 2017-03-30 03:04 -0700
            Re: bug in VFX --- IF does't work Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-30 06:47 -0500
              Re: bug in VFX --- IF does't work Alex <alex@rivadpm.com> - 2017-03-30 12:56 +0100
                Re: bug in VFX --- IF does't work Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-30 09:41 -0500
              Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-30 13:59 -0700
              Re: bug in VFX --- IF does't work Bernd Paysan <bernd@net2o.de> - 2017-05-01 01:33 +0000
                Re: bug in VFX --- IF does't work "Elizabeth D. Rather" <erather@forth.com> - 2017-04-30 15:50 -1000
                Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-04-30 19:34 -0700
                Re: bug in VFX --- IF does't work albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-01 23:53 +0200
                Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-05-01 18:54 -0700
                Re: bug in VFX --- IF does't work Bernd Paysan <bernd@net2o.de> - 2017-05-02 15:01 +0000
                Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-05-02 11:30 -0700
                Re: bug in VFX --- IF does't work Cecil Bayona <cbayona@cbayona.com> - 2017-05-02 13:36 -0500
                Re: bug in VFX --- IF does't work Bernd Paysan <bernd@net2o.de> - 2017-05-02 22:57 +0000
          Re: bug in VFX --- IF does't work anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-31 09:45 +0000
            Re: bug in VFX --- IF does't work hughaguilar96@gmail.com - 2017-03-31 20:09 -0700

csiph-web