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


Groups > comp.lang.forth > #44038

Re: Ann: ANS/FORTH 2012 test suite update

From Gerry Jackson <gerry@jackson9000.fsnet.co.uk>
Newsgroups comp.lang.forth
Subject Re: Ann: ANS/FORTH 2012 test suite update
Date 2015-12-02 10:08 +0000
Organization A noiseless patient Spider
Message-ID <n3mfpb$gh3$1@dont-email.me> (permalink)
References (6 earlier) <a94414af-6598-4881-87ff-b561f9a93f7a@googlegroups.com> <n3g4qm$aej$1@dont-email.me> <n3h53t$s5v$1@dont-email.me> <2015Nov30.190422@mips.complang.tuwien.ac.at> <n3iesv$62i$1@dont-email.me>

Show all headers | View raw


On 30/11/2015 21:28, Gerry Jackson wrote:
> On 30/11/2015 18:04, Anton Ertl wrote:
>> Gerry Jackson <gerry@jackson9000.fsnet.co.uk> writes:
>>> On 30/11/2015 00:24, Bernd Paysan wrote:
>>>> We recently changed Gforth so that it only warns when compile-only
>>>> words are
>>>> encountered with ' or the interpreter, and as part of that,
>>>> NAME>INTERPRET
>>>> has been changed not to return 0.
>>>
>>> You still can query the flags with
>>>> COMPILE-ONLY? ( nt -- flag ), so we could implement a NAME>INTERPRET
>>>> which
>>>> returns 0 in that case.
>>
>> I think the current approach (return the same value as ' does) is
>> better, for the same reasons that it is better to make these words
>> tickable and interpretable: It's more uniform, it's more traditional,
>> and it's easier to program for (no special-casing for 0 is necessary).
>>
>>> So does NAME>INTERPRET return an xt that can be executed to do something
>>> useful i.e. do something other than output a warning or throwing an
>>> error.
>>
>> If you NAME>INTERPRET or ' IF, you get the xt for the compilation
>> semantics of IF, and I think that's also the case for all the other
>> remaining compile-only words.  Likewise, if you text-interpret IF (in
>> either state), the text interpreter will perform the compilation
>> semantics (so they have all become immediate in every sense, not just
>> "immediate-but-...").  Example:
>>
>> : foo [ if ] ." foo" then ;
>> :1: warning: IF is compile-only ok
>> 0 foo  ok
>> 1 foo foo ok
>> : bar [ ' if execute ] ." bar" then ;
>> :4: warning: IF is compile-only ok
>> 0 bar  ok
>> 1 bar bar ok
>
> Why would anyone want to do that when it is easier to write e.g.
> : foo if ." foo" then ;
>
> What happens then if someone types e.g.
> if           \ or
> ' if execute
> Does Gforth just issue a warning and then compile some code that is
> inaccesible and therefore useless? Also leaving control-flow information
> on the stack?
>

Yes, I tried it since you didn't answer:

-------------
Gforth 0.7.9_20151126, Copyright (C) 1995-2015 Free Software Foundation, 
Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit
' if execute .s
:1: warning: IF is compile-only<3> 0 2143238672 2  ok
drop 2drop  ok
here . 2143238676  ok
if ." inaccessible code" then .s
:4: warning: IF is compile-onlyinaccessible code
:4: warning: THEN is compile-only<0>  ok
here . 2143238684  ok
-------------

I see it displayed the message after the warning so I tried:

-------------
-1 if cr ." Should display" cr then .s
:16: warning: IF is compile-only
Should display

:16: warning: THEN is compile-only<1> -1  ok
drop  ok
   ok
0 if cr ." Should not display" cr then .s
:19: warning: IF is compile-only
Should not display

:19: warning: THEN is compile-only<1> 0  ok
-------------

So GForth interprets the line, compiling stuff because of the IF ... 
THEN, but the IF ... THEN are otherwise noops as far as the interpreting 
is concerned.

I realise that this is misusing IF and THEN and, from your previous 
description, I can understand the logic behind GForth doing this. But I 
think I'll stick with being able to tick IF and throwing an exception if 
IF's xt is executed, particularly as no convincing use case has been 
suggested as yet.
-- 
Gerry

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


Thread

Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-27 20:06 +0000
  Re: Ann: ANS/FORTH 2012 test suite update Aliaksei Chapyzhenka <alex.drom@gmail.com> - 2015-11-27 22:19 -0800
  Re: Ann: ANS/FORTH 2012 test suite update peter.m.falth@gmail.com - 2015-11-28 10:07 -0800
    Re: Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-29 10:13 +0000
    Re: Ann: ANS/FORTH 2012 test suite update "steve@srpalmer.me.uk" <steverpalmer27@gmail.com> - 2015-11-29 03:47 -0800
      Re: Ann: ANS/FORTH 2012 test suite update Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-29 12:41 +0000
      Re: Ann: ANS/FORTH 2012 test suite update anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-29 12:41 +0000
      Re: Ann: ANS/FORTH 2012 test suite update peter.m.falth@gmail.com - 2015-11-29 08:41 -0800
        Re: Ann: ANS/FORTH 2012 test suite update peter.m.falth@gmail.com - 2015-11-29 10:47 -0800
          Re: Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-29 20:29 +0000
            Re: Ann: ANS/FORTH 2012 test suite update peter.m.falth@gmail.com - 2015-11-29 14:44 -0800
              Re: Ann: ANS/FORTH 2012 test suite update Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-30 01:24 +0100
                Re: Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-30 09:35 +0000
                Re: Ann: ANS/FORTH 2012 test suite update anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-30 18:04 +0000
                Re: Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-30 21:28 +0000
                Re: Ann: ANS/FORTH 2012 test suite update Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-30 22:59 +0100
                Re: Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-12-01 12:29 +0000
                Re: Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-12-02 10:08 +0000
                Re: Ann: ANS/FORTH 2012 test suite update anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-05 15:57 +0000
              Re: Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-30 09:49 +0000
                Re: Ann: ANS/FORTH 2012 test suite update anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-30 18:16 +0000
                Re: Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-30 21:28 +0000
              Re: Ann: ANS/FORTH 2012 test suite update Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-30 10:25 +0000
          Re: Ann: ANS/FORTH 2012 test suite update "Elizabeth D. Rather" <erather@forth.com> - 2015-11-29 13:14 -1000
          Re: Ann: ANS/FORTH 2012 test suite update steverpalmer27@gmail.com - 2015-11-30 03:51 -0800
            Re: Ann: ANS/FORTH 2012 test suite update peter.m.falth@gmail.com - 2015-11-30 09:00 -0800
              Re: Ann: ANS/FORTH 2012 test suite update "Elizabeth D. Rather" <erather@forth.com> - 2015-11-30 07:54 -1000
                Re: Ann: ANS/FORTH 2012 test suite update Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-30 18:25 +0000
                Re: Ann: ANS/FORTH 2012 test suite update "Elizabeth D. Rather" <erather@forth.com> - 2015-11-30 11:06 -1000
      Re: Ann: ANS/FORTH 2012 test suite update "Elizabeth D. Rather" <erather@forth.com> - 2015-11-29 13:08 -1000

csiph-web