Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #39458 > unrolled thread
| Started by | josv@planet.nl |
|---|---|
| First post | 2015-05-30 07:41 -0700 |
| Last post | 2015-06-09 17:51 +1000 |
| Articles | 20 on this page of 46 — 11 participants |
Back to article view | Back to comp.lang.forth
\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
Page 1 of 3 [1] 2 3 Next page →
| From | josv@planet.nl |
|---|---|
| Date | 2015-05-30 07:41 -0700 |
| Subject | \s |
| Message-ID | <25fcb068-f469-4351-8d6c-1e9dfd803448@googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-05-30 09:01 -0700 |
| Message-ID | <d65af649-6c97-43df-9484-6d917753ffee@googlegroups.com> |
| In reply to | #39458 |
On Saturday, May 30, 2015 at 7:41:28 AM UTC-7, jo...@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
That looks fine, except that I don't think it should be immediate --- you would never do this inside of a colon word.
Also, I would recommend changing the name to this: TESTING...
You would normally put this at the end of a file and follow it with testing words. For testing, you comment out the TESTING... line with \ but for the production version you leave TESTING... in so your testing code doesn't get compiled.
I may put TESTING... in the novice-package --- I will give you credit if you tell me your name.
In the novice-package, I already have this:
: comment ( delimiter -- ) \ The & usually works.
begin dup parse? nip nip while
refill 0= abort" *** COMMENT never found its delimiter ***"
repeat
drop ;
: & ( -- )
cr ." warning: we are using the code that had been commented out previously" ;
[toc] | [prev] | [next] | [standalone]
| From | josv@planet.nl |
|---|---|
| Date | 2015-05-30 09:59 -0700 |
| Message-ID | <5fc42de4-1fd5-4bb0-991b-063c81ae735d@googlegroups.com> |
| In reply to | #39460 |
Hi, \s exists in Win32Forth and in FPC, so it is not entirely my invention. The problem is that the code could not be used in Gforth. I use it mostly to indicate the end of my source. So I know it is still complete. Since it is immediate in Win32Forth I made it again immediate. It is indeed not clear to me why is immediate in Win32Forth. Regards, Jos On May 30th, 2015 18:01:40 UTC+2 hughag...@gmail.com wrote: > On Saturday, May 30, 2015 at 7:41:28 AM UTC-7, jo...@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 > > That looks fine, except that I don't think it should be immediate --- you would never do this inside of a colon word. > > Also, I would recommend changing the name to this: TESTING... > You would normally put this at the end of a file and follow it with testing words. For testing, you comment out the TESTING... line with \ but for the production version you leave TESTING... in so your testing code doesn't get compiled. > > I may put TESTING... in the novice-package --- I will give you credit if you tell me your name. > > In the novice-package, I already have this: > > : comment ( delimiter -- ) \ The & usually works. > begin dup parse? nip nip while > refill 0= abort" *** COMMENT never found its delimiter ***" > repeat > drop ; > > : & ( -- ) > cr ." warning: we are using the code that had been commented out previously" ;
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-05-30 11:45 -0700 |
| Message-ID | <fda8a1b8-08a7-42f4-a1e4-ac7462888712@googlegroups.com> |
| In reply to | #39464 |
On Saturday, May 30, 2015 at 9:59:35 AM UTC-7, jo...@planet.nl wrote: > Hi, > \s exists in Win32Forth and in FPC, so it is not entirely my invention. > The problem is that the code could not be used in Gforth. > I use it mostly to indicate the end of my source. So I know it is still complete. > Since it is immediate in Win32Forth I made it again immediate. > It is indeed not clear to me why is immediate in Win32Forth. > > Regards, Jos > > On May 30th, 2015 18:01:40 UTC+2 hughag...@gmail.com wrote: > > On Saturday, May 30, 2015 at 7:41:28 AM UTC-7, jo...@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 > > > > That looks fine, except that I don't think it should be immediate --- you would never do this inside of a colon word. > > > > Also, I would recommend changing the name to this: TESTING... > > You would normally put this at the end of a file and follow it with testing words. For testing, you comment out the TESTING... line with \ but for the production version you leave TESTING... in so your testing code doesn't get compiled. > > > > I may put TESTING... in the novice-package --- I will give you credit if you tell me your name. > > > > In the novice-package, I already have this: > > > > : comment ( delimiter -- ) \ The & usually works. > > begin dup parse? nip nip while > > refill 0= abort" *** COMMENT never found its delimiter ***" > > repeat > > drop ; > > > > : & ( -- ) > > cr ." warning: we are using the code that had been commented out previously" ; It hangs the system when used on the command-line --- this makes it dangerous --- I may just stick with COMMENT that does everything I need.
[toc] | [prev] | [next] | [standalone]
| From | josv@planet.nl |
|---|---|
| Date | 2015-05-30 13:06 -0700 |
| Message-ID | <fcbfc6a0-348b-4158-98e0-784381e6dbb3@googlegroups.com> |
| In reply to | #39467 |
Hi,
Thanks for testing it on the command line.
It made me change de code for Gforth as follows:
: \s ( -- )
loadfile @
if begin refill 0= until
else [ ' \ ] literal
then
; immediate
Jos
May 30th, 2015 20:45:31 UTC+2 hughag...@gmail.com wrote:
> On Saturday, May 30, 2015 at 9:59:35 AM UTC-7, jo...@planet.nl wrote:
> > Hi,
> > \s exists in Win32Forth and in FPC, so it is not entirely my invention.
> > The problem is that the code could not be used in Gforth.
> > I use it mostly to indicate the end of my source. So I know it is still complete.
> > Since it is immediate in Win32Forth I made it again immediate.
> > It is indeed not clear to me why is immediate in Win32Forth.
> >
> > Regards, Jos
> >
> > On May 30th, 2015 18:01:40 UTC+2 hughag...@gmail.com wrote:
> > > On Saturday, May 30, 2015 at 7:41:28 AM UTC-7, jo...@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
> > >
> > > That looks fine, except that I don't think it should be immediate --- you would never do this inside of a colon word.
> > >
> > > Also, I would recommend changing the name to this: TESTING...
> > > You would normally put this at the end of a file and follow it with testing words. For testing, you comment out the TESTING... line with \ but for the production version you leave TESTING... in so your testing code doesn't get compiled.
> > >
> > > I may put TESTING... in the novice-package --- I will give you credit if you tell me your name.
> > >
> > > In the novice-package, I already have this:
> > >
> > > : comment ( delimiter -- ) \ The & usually works.
> > > begin dup parse? nip nip while
> > > refill 0= abort" *** COMMENT never found its delimiter ***"
> > > repeat
> > > drop ;
> > >
> > > : & ( -- )
> > > cr ." warning: we are using the code that had been commented out previously" ;
>
> It hangs the system when used on the command-line --- this makes it dangerous --- I may just stick with COMMENT that does everything I need.
[toc] | [prev] | [next] | [standalone]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2015-05-30 20:32 +0100 |
| Message-ID | <mkd35v$e9o$1@dont-email.me> |
| In reply to | #39458 |
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
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-05-31 21:48 -0700 |
| Message-ID | <b7eb696f-a63f-440f-9eb0-70ffa10c6026@googlegroups.com> |
| In reply to | #39468 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2015-06-01 08:27 +0100 |
| Message-ID | <mkh1fc$l0b$1@dont-email.me> |
| In reply to | #39494 |
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
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-06-09 17:11 -0700 |
| Message-ID | <e8eca1cf-3ee5-42c0-85aa-977581f61634@googlegroups.com> |
| In reply to | #39494 |
On Sunday, May 31, 2015 at 9:48:41 PM UTC-7, hughag...@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. This doesn't work. It was crashing when I had an INCLUDE of one file in another file. I'm going to drop all of this --- my COMMENT works fine and is all that is needed --- this stuff isn't really worth much, and it is becoming a big hassle.
[toc] | [prev] | [next] | [standalone]
| From | josv@planet.nl |
|---|---|
| Date | 2015-06-10 04:03 -0700 |
| Message-ID | <f01a7eed-9206-4c31-bb60-da048860a225@googlegroups.com> |
| In reply to | #39675 |
On June 10th, 2015 02:11:03 UTC+2 hughag...@gmail.com wrote : > On Sunday, May 31, 2015 at 9:48:41 PM UTC-7, hughag...@gmail.com wrote: > > On Saturday, May 30, 2015 at 12:32:25 PM UTC-7, Gerry wrote: > > > On 30/05/2015 15:41, jo...@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. > > This doesn't work. It was crashing when I had an INCLUDE of one file in another file. > > I'm going to drop all of this --- my COMMENT works fine and is all that is needed --- this stuff isn't really worth much, and it is becoming a big hassle. Thank you for the effort. Meanwhile I got an easy way out in Gforth by using: ' \\\ alias \s Sorry for the hassle. Jos
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2015-05-30 22:42 +0200 |
| Message-ID | <snisvwqwkhxj$.15cqynm0bwvh9$.dlg@40tude.net> |
| In reply to | #39458 |
Op Sat, 30 May 2015 07:41:26 -0700 (PDT) schreef josv@planet.nl: > 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 Correction, as someone said, not immediate. -- Coos CHForth, 16 bit DOS applications http://home.hccnet.nl/j.j.haak/forth.html
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2015-05-30 22:40 +0200 |
| Message-ID | <1jnkxw39fip4e$.1ii54m7apdnsm.dlg@40tude.net> |
| In reply to | #39458 |
Op Sat, 30 May 2015 07:41:26 -0700 (PDT) schreef josv@planet.nl: > 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 I have : \S stop on source nip >in ! ; immediate Where stop is a variable that is cleared by the include-file loop and tested after interpreting the line. Include-file closes the file as normal and finishes normally. This way senseless refills are not necessary, especially in the time computers ran in the MHz range. -- Coos CHForth, 16 bit DOS applications http://home.hccnet.nl/j.j.haak/forth.html
[toc] | [prev] | [next] | [standalone]
| From | josv@planet.nl |
|---|---|
| Date | 2015-05-30 14:12 -0700 |
| Message-ID | <d77b2cd1-89dd-4553-9887-15288dd0f50a@googlegroups.com> |
| In reply to | #39474 |
Hi Coos, Your version looks interesting. But why is it immediate ? Jos On May 30th, 2015 22:52:02 UTC+2 Coos Haak wrote: > Op Sat, 30 May 2015 07:41:26 -0700 (PDT) schreef j...@planet.nl: > > > 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 > > I have > : \S stop on source nip >in ! ; immediate > > Where stop is a variable that is cleared by the include-file loop and > tested after interpreting the line. Include-file closes the file as normal > and finishes normally. This way senseless refills are not necessary, > especially in the time computers ran in the MHz range. > > -- > Coos > > CHForth, 16 bit DOS applications > http://home.hccnet.nl/j.j.haak/forth.html
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2015-06-03 15:10 +1000 |
| Message-ID | <mkm25m$urg$1@speranza.aioe.org> |
| In reply to | #39474 |
Coos Haak wrote: > ... > I have > : \S stop on source nip >in ! ; immediate > > Where stop is a variable that is cleared by the include-file loop and > tested after interpreting the line. Include-file closes the file as normal > and finishes normally. This way senseless refills are not necessary, > especially in the time computers ran in the MHz range. "senseless refills" occur all the time. Consider the number of comment lines in a typical forth source. Time spent reading and discarding these will far outweigh anything saved by a 'smart' but occasional \S. I assume you use STOP for things other than \S. In that case your implementation appears to be both short and appropriate.
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2015-06-03 13:58 +0200 |
| Message-ID | <nruq22fvqu7$.x8sswaat1vz4$.dlg@40tude.net> |
| In reply to | #39534 |
Op Wed, 3 Jun 2015 15:10:12 +1000 schreef HAA: > Coos Haak wrote: >> ... >> I have >>: \S stop on source nip >in ! ; immediate >> >> Where stop is a variable that is cleared by the include-file loop and >> tested after interpreting the line. Include-file closes the file as normal >> and finishes normally. This way senseless refills are not necessary, >> especially in the time computers ran in the MHz range. > > "senseless refills" occur all the time. Consider the number of comment > lines in a typical forth source. Time spent reading and discarding these > will far outweigh anything saved by a 'smart' but occasional \S. > > I assume you use STOP for things other than \S. In that case your > implementation appears to be both short and appropriate. No, I use STOP only in INCLUDE-FILE. Can you think of other use? -- Coos CHForth, 16 bit DOS applications http://home.hccnet.nl/j.j.haak/forth.html
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2015-06-05 21:42 +1000 |
| Message-ID | <mks1ui$s8k$1@speranza.aioe.org> |
| In reply to | #39540 |
Coos Haak wrote: > Op Wed, 3 Jun 2015 15:10:12 +1000 schreef HAA: > > > Coos Haak wrote: > >> ... > >> I have > >>: \S stop on source nip >in ! ; immediate > >> > >> Where stop is a variable that is cleared by the include-file loop and > >> tested after interpreting the line. Include-file closes the file as normal > >> and finishes normally. This way senseless refills are not necessary, > >> especially in the time computers ran in the MHz range. > > > > "senseless refills" occur all the time. Consider the number of comment > > lines in a typical forth source. Time spent reading and discarding these > > will far outweigh anything saved by a 'smart' but occasional \S. > > > > I assume you use STOP for things other than \S. In that case your > > implementation appears to be both short and appropriate. > > No, I use STOP only in INCLUDE-FILE. Can you think of other use? Never considered it because senseless REFILLs worked fine for me
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2015-05-31 14:46 +0000 |
| Message-ID | <556b1eaf$0$23284$e4fe514c@dreader34.news.xs4all.nl> |
| In reply to | #39458 |
In article <25fcb068-f469-4351-8d6c-1e9dfd803448@googlegroups.com>, <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? EXIT >Jos -- 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]
| From | josv@planet.nl |
|---|---|
| Date | 2015-05-31 09:38 -0700 |
| Message-ID | <597faa57-4207-4f29-884a-c95ca7da3e90@googlegroups.com> |
| In reply to | #39479 |
Hi Albert, Shorter: Yes, Better: No, I got: Interpreting a compile-only word Jos On May 31st, 2015 16:46:42 UTC+2 Albert van der Horst wrote: > In article <25fcb068-f469-4351-8d6c-1e9dfd......@googlegroups.com>, > <j...@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? > > EXIT > > > >Jos > -- > Albert van der Horst, UTRECHT,THE NETHERLANDS > Economic growth -- being exponential -- ultimately falters. > a....&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2015-06-01 10:58 +0000 |
| Message-ID | <556c3aeb$0$21289$e4fe514c@dreader37.news.xs4all.nl> |
| In reply to | #39481 |
In article <597faa57-4207-4f29-884a-c95ca7da3e90@googlegroups.com>, <josv@planet.nl> wrote: >Hi Albert, > >Shorter: Yes, Better: No, I got: Interpreting a compile-only word > >Jos > >On May 31st, 2015 16:46:42 UTC+2 Albert van der Horst wrote: >> In article <25fcb068-f469-4351-8d6c-1e9dfd......@googlegroups.com>, >> <j...@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? >> >> EXIT Please don't top-post You said that it doesn't work. But I think the EXIT word should work in interpreted mode. : test " 1 2 3 EXIT 4 5 6 " EVALUATE ; Should behave the same as : test 1 2 3 EXIT 4 5 6 ; In other words EXIT in interpreted mode should abandon the current interpret source, while QUIT abandons all nested interpreter loop to the uppermost. Makes sense. In ciforth it works like this. It is not STATE-smart. It doesn't inspect STATE. You just say EXIT to the interpreter and it ... well exits. So the behaviour is a side effect of a good design (if I might say so). >> >> >> >Jos > 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]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2015-05-31 21:04 +0100 |
| Message-ID | <mkfpcv$uck$1@dont-email.me> |
| In reply to | #39458 |
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
>
Another possibility is to get the size of the file and set the file
pointer position to that value. e.g. (untested)
: \s source-id file-size throw ( -- ud )
source-id reposition-file throw ( -- )
;
However the Forth 200X committee decided that was not a valid thing to
do and banned it in the Forth 2012 document. But IIRC it used to work in
GForth and perhaps still does.
--
Gerry
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.forth
csiph-web