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


Groups > comp.lang.forth > #39496

Re: \s

From Gerry Jackson <gerry@jackson9000.fsnet.co.uk>
Newsgroups comp.lang.forth
Subject Re: \s
Date 2015-06-01 08:27 +0100
Organization A noiseless patient Spider
Message-ID <mkh1fc$l0b$1@dont-email.me> (permalink)
References <25fcb068-f469-4351-8d6c-1e9dfd803448@googlegroups.com> <mkd35v$e9o$1@dont-email.me> <b7eb696f-a63f-440f-9eb0-70ffa10c6026@googlegroups.com>

Show all headers | View raw


On 01/06/2015 05:48, hughaguilar96@gmail.com wrote:
> On Saturday, May 30, 2015 at 12:32:25 PM UTC-7, Gerry wrote:
>> On 30/05/2015 15:41, josv@planet.nl wrote:
>>> Hi,
>>>
>>> \s can be used to skip the rest of a source when it is compiled.
>>> For Gforth the following seems to work.
>>>
>>> : \s  ( -- )  begin  refill 0= until ; immediate
>>>
>>> Is there a shorter or better way?
>>> Jos
>>>
>>
>> You could throw an exception e.g.
>>
>> : \s abort ;
>>
>> \ and include the file with
>>
>> s" path\filename.fth" ' included catch drop 2drop
>>
>> --
>> Gerry
>
> Well, I tried this code and it worked:
>
> : testing... ( -- )                         \ comments out the remainder of the file
>      abort ;
>
> : included ( adr cnt -- )
>      included  catch drop 2drop ;
>
> : include ( -- )                            \ stream: filename
>      postpone s"  included ;
>
> The problem however, is that S" is being used in interpretive-mode (assuming that INCLUDE is being used in interpretive mode) --- but S" is one of the "interpretation semantics for this word are undefined" pit-falls. This is despite the fact that INCLUDE is almost certainly written like this internally.
>

But the File-Access word set extends S" to work in interpretation mode, 
see 11.6.1.2165 of the ANS Forth or Forth 2012 document.

Actually my code is incorrect, if \s is not used in the included file, 
we get stack underflow. It should be

s" path\filename.fth" ' included catch [if] 2drop [then]

One drawback is that this doesn't distinguish between the use of \s and 
other exceptions e.g. file not opened. So an 'early end of file' 
exception code is needed.

-- 
Gerry

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


Thread

\s josv@planet.nl - 2015-05-30 07:41 -0700
  Re: \s hughaguilar96@gmail.com - 2015-05-30 09:01 -0700
    Re: \s josv@planet.nl - 2015-05-30 09:59 -0700
      Re: \s hughaguilar96@gmail.com - 2015-05-30 11:45 -0700
        Re: \s josv@planet.nl - 2015-05-30 13:06 -0700
  Re: \s Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-05-30 20:32 +0100
    Re: \s hughaguilar96@gmail.com - 2015-05-31 21:48 -0700
      Re: \s Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-06-01 08:27 +0100
      Re: \s hughaguilar96@gmail.com - 2015-06-09 17:11 -0700
        Re: \s josv@planet.nl - 2015-06-10 04:03 -0700
  Re: \s Coos Haak <chforth@hccnet.nl> - 2015-05-30 22:42 +0200
  Re: \s Coos Haak <chforth@hccnet.nl> - 2015-05-30 22:40 +0200
    Re: \s josv@planet.nl - 2015-05-30 14:12 -0700
    Re: \s "HAA" <someone@microsoft.com> - 2015-06-03 15:10 +1000
      Re: \s Coos Haak <chforth@hccnet.nl> - 2015-06-03 13:58 +0200
        Re: \s "HAA" <someone@microsoft.com> - 2015-06-05 21:42 +1000
  Re: \s albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-05-31 14:46 +0000
    Re: \s josv@planet.nl - 2015-05-31 09:38 -0700
      Re: \s albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-06-01 10:58 +0000
  Re: \s Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-05-31 21:04 +0100
    Re: \s Bernd Paysan <bernd.paysan@gmx.de> - 2015-05-31 22:14 +0200
      Re: \s "HAA" <someone@microsoft.com> - 2015-06-01 13:44 +1000
        Re: \s Coos Haak <chforth@hccnet.nl> - 2015-06-01 12:17 +0200
          Re: \s "HAA" <someone@microsoft.com> - 2015-06-03 12:55 +1000
            Re: \s Bernd Paysan <bernd.paysan@gmx.de> - 2015-06-03 16:39 +0200
              Re: \s "HAA" <someone@microsoft.com> - 2015-06-05 21:36 +1000
                Re: \s Coos Haak <chforth@hccnet.nl> - 2015-06-05 13:54 +0200
                Re: \s "HAA" <someone@microsoft.com> - 2015-06-13 16:20 +1000
                Re: \s coos <chforth@hccnet.nl> - 2015-06-13 21:34 +0200
                Re: \s "Alex McDonald" <blog@rivadpm.com> - 2015-06-16 20:51 +0100
                Re: \s Mark Wills <markwills1970@gmail.com> - 2015-06-17 01:06 -0700
                Re: \s coos <chforth@hccnet.nl> - 2015-06-17 16:15 +0200
                Re: \s coos <chforth@hccnet.nl> - 2015-06-17 16:28 +0200
                Re: \s Bernd Paysan <bernd.paysan@gmx.de> - 2015-06-08 01:10 +0200
                Re: \s anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-06-08 07:56 +0000
                Re: \s Bernd Paysan <bernd.paysan@gmx.de> - 2015-06-08 17:12 +0200
                Re: \s "HAA" <someone@microsoft.com> - 2015-06-09 17:53 +1000
                Re: \s Bernd Paysan <bernd.paysan@gmx.de> - 2015-06-09 23:40 +0200
                Re: \s hughaguilar96@gmail.com - 2015-06-13 22:46 -0700
                Re: \s coos <chforth@hccnet.nl> - 2015-06-14 17:01 +0200
                Re: \s hughaguilar96@gmail.com - 2015-06-14 10:32 -0700
                Re: \s coos <chforth@hccnet.nl> - 2015-06-14 17:00 +0200
            Re: \s Mark Wills <markwills1970@gmail.com> - 2015-06-05 05:13 -0700
              Re: \s Coos Haak <chforth@hccnet.nl> - 2015-06-05 14:37 +0200
                Re: \s Mark Wills <markwills1970@gmail.com> - 2015-06-05 10:28 -0700
      Re: \s "HAA" <someone@microsoft.com> - 2015-06-09 17:51 +1000

csiph-web