Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

\s

362 views
Skip to first unread message

jo...@planet.nl

unread,
May 30, 2015, 10:41:28 AM5/30/15
to
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

hughag...@gmail.com

unread,
May 30, 2015, 12:01:40 PM5/30/15
to
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" ;

jo...@planet.nl

unread,
May 30, 2015, 12:59:35 PM5/30/15
to
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

hughag...@gmail.com

unread,
May 30, 2015, 2:45:31 PM5/30/15
to
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.

Gerry Jackson

unread,
May 30, 2015, 3:32:25 PM5/30/15
to
You could throw an exception e.g.

: \s abort ;

\ and include the file with

s" path\filename.fth" ' included catch drop 2drop

--
Gerry

jo...@planet.nl

unread,
May 30, 2015, 4:06:59 PM5/30/15
to
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

Coos Haak

unread,
May 30, 2015, 4:48:03 PM5/30/15
to
Op Sat, 30 May 2015 07:41:26 -0700 (PDT) schreef jo...@planet.nl:
Correction, as someone said, not immediate.
--
Coos

CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html

Coos Haak

unread,
May 30, 2015, 4:52:02 PM5/30/15
to
Op Sat, 30 May 2015 07:41:26 -0700 (PDT) schreef jo...@planet.nl:

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.

jo...@planet.nl

unread,
May 30, 2015, 5:12:57 PM5/30/15
to
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:

Albert van der Horst

unread,
May 31, 2015, 10:46:42 AM5/31/15
to
In article <25fcb068-f469-4351...@googlegroups.com>,
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

jo...@planet.nl

unread,
May 31, 2015, 12:38:37 PM5/31/15
to
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

Gerry Jackson

unread,
May 31, 2015, 4:03:53 PM5/31/15
to
On 30/05/2015 15:41, jo...@planet.nl wrote:
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

Bernd Paysan

unread,
May 31, 2015, 4:14:52 PM5/31/15
to
Gerry Jackson wrote:
> : \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.

It's not something you can rely on.

> But IIRC it used to work in GForth and perhaps still does.

My point of view is that a quality implementation should honor this,
following the principle of least surprise. If you want to optimize, e.g.
slurp in the entire file (or bigger chunks of it) and then present it line
by line to the interpreter, you can as well implement FILE-POSITION and
REPOSITION-FILE in a way which works on buffers. After all, we do use C's
io buffers in Gforth, which work like that.

You should add a POSTPONE \ to make sure that the rest of the \S line is
also commented out.

BTW: no need to implement it, Gforth already has \\\ which has the same
effect. It's implemented portably, i.e. it first does the REPOSITION-FILE
thing, and then a REFILL loop, and finally the POSTPONE \.

--
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/

HAA

unread,
May 31, 2015, 11:43:48 PM5/31/15
to
Bernd Paysan wrote:
> ...
> BTW: no need to implement it, Gforth already has \\\ which has the same
> effect. It's implemented portably, i.e. it first does the REPOSITION-FILE
> thing, and then a REFILL loop, and finally the POSTPONE \.

Block file support? Skipping the remainder of a block was originally done
with EXIT but that's not possible on many systems today.



hughag...@gmail.com

unread,
Jun 1, 2015, 12:48:41 AM6/1/15
to
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.

Gerry Jackson

unread,
Jun 1, 2015, 3:27:50 AM6/1/15
to
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

Coos Haak

unread,
Jun 1, 2015, 6:20:52 AM6/1/15
to
Op Mon, 1 Jun 2015 13:44:29 +1000 schreef HAA:
Yes, but blocks consist of tekst without end-of-line markers, text files
do. Notable exception: ciforth.
In blocks my \s does work.

Albert van der Horst

unread,
Jun 1, 2015, 6:58:53 AM6/1/15
to
In article <597faa57-4207-4f29...@googlegroups.com>,
<jo...@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

HAA

unread,
Jun 2, 2015, 11:04:13 PM6/2/15
to
Coos Haak wrote:
> Op Mon, 1 Jun 2015 13:44:29 +1000 schreef HAA:
>
> > Bernd Paysan wrote:
> >> ...
> >> BTW: no need to implement it, Gforth already has \\\ which has the same
> >> effect. It's implemented portably, i.e. it first does the REPOSITION-FILE
> >> thing, and then a REFILL loop, and finally the POSTPONE \.
> >
> > Block file support? Skipping the remainder of a block was originally done
> > with EXIT but that's not possible on many systems today.
>
> Yes, but blocks consist of tekst without end-of-line markers, text files
> do. Notable exception: ciforth.
> In blocks my \s does work.

Perhaps Bernd will adopt your implementation.



HAA

unread,
Jun 3, 2015, 1:09:14 AM6/3/15
to
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.



Coos Haak

unread,
Jun 3, 2015, 8:02:03 AM6/3/15
to
Op Wed, 3 Jun 2015 15:10:12 +1000 schreef HAA:
No, I use STOP only in INCLUDE-FILE. Can you think of other use?

Bernd Paysan

unread,
Jun 3, 2015, 10:39:16 AM6/3/15
to
Block remainder skipping is usually called \\, but Gforth doesn't have it,
because very few people use blocks ;-).

Implementation is trivial, though.

HAA

unread,
Jun 5, 2015, 7:40:01 AM6/5/15
to
Bernd Paysan wrote:
> HAA wrote:
>
> > Coos Haak wrote:
> >> Op Mon, 1 Jun 2015 13:44:29 +1000 schreef HAA:
> >>
> >> > Bernd Paysan wrote:
> >> >> ...
> >> >> BTW: no need to implement it, Gforth already has \\\ which has the
> >> >> same
> >> >> effect. It's implemented portably, i.e. it first does the
> >> >> REPOSITION-FILE thing, and then a REFILL loop, and finally the
> >> >> POSTPONE \.
> >> >
> >> > Block file support? Skipping the remainder of a block was originally
> >> > done with EXIT but that's not possible on many systems today.
> >>
> >> Yes, but blocks consist of tekst without end-of-line markers, text files
> >> do. Notable exception: ciforth.
> >> In blocks my \s does work.
> >
> > Perhaps Bernd will adopt your implementation.
>
> Block remainder skipping is usually called \\, but Gforth doesn't have it,
> because very few people use blocks ;-).

Blocks are still in 200x ?

> Implementation is trivial, though.

Agreed

: \\
is-current-source-a-text-file? if
begin refill 0= until
else ( keyboard, block file or Evaluate)
source >in ! drop
then ; immediate

It's Immediate only because \ and ( are.



HAA

unread,
Jun 5, 2015, 7:42:14 AM6/5/15
to
Never considered it because senseless REFILLs worked fine for me



Coos Haak

unread,
Jun 5, 2015, 8:06:02 AM6/5/15
to
Op Fri, 5 Jun 2015 21:36:54 +1000 schreef HAA:

> Bernd Paysan wrote:
>> HAA wrote:
>>
>>> Coos Haak wrote:
>>>> Op Mon, 1 Jun 2015 13:44:29 +1000 schreef HAA:
>>>>
>>>> > Bernd Paysan wrote:
>>>> >> ...
>>>> >> BTW: no need to implement it, Gforth already has \\\ which has the
>>>> >> same
>>>> >> effect. It's implemented portably, i.e. it first does the
>>>> >> REPOSITION-FILE thing, and then a REFILL loop, and finally the
>>>> >> POSTPONE \.
>>>> >
>>>> > Block file support? Skipping the remainder of a block was originally
>>>> > done with EXIT but that's not possible on many systems today.
>>>>
>>>> Yes, but blocks consist of tekst without end-of-line markers, text files
>>>> do. Notable exception: ciforth.
>>>> In blocks my \s does work.
>>>
>>> Perhaps Bernd will adopt your implementation.
>>
>> Block remainder skipping is usually called \\, but Gforth doesn't have it,
>> because very few people use blocks ;-).
>
> Blocks are still in 200x ?

It's even mandate to have the BLOCK wordset if you have the FILE wordset.
But I could live without.

>
>> Implementation is trivial, though.
>
> Agreed
>
>: \\
> is-current-source-a-text-file? if
> begin refill 0= until
> else ( keyboard, block file or Evaluate)
> source >in ! drop
> then ; immediate

Too much code.
>
> It's Immediate only because \ and ( are.
It's not a comment: what if you by accident place it in the body of a
definition. You're still in compile mode.
At least use something like ?EXEC.

Mark Wills

unread,
Jun 5, 2015, 8:13:23 AM6/5/15
to
Just set >IN to a value greater than the size of the TIB, surely?

In my system I have #TIB which reports the size of the TIB. When
processing a block the size of the TIB is 1024 (because I relocate TIB
to the same address as the block buffer).

Therefore:

: \s ( -- ) 50000 >IN ! ;

...would work just fine.

:-)

Coos Haak

unread,
Jun 5, 2015, 8:46:01 AM6/5/15
to
Op Fri, 5 Jun 2015 05:13:22 -0700 (PDT) schreef Mark Wills:
Why exactly this random number, 'SOURCE NIP >IN !' suffices. Your SOURCE
has 1024 on top when loading a block, I might presume?
When you mmap a file, the size may be bigger than 50000.

Mark Wills

unread,
Jun 5, 2015, 1:28:15 PM6/5/15
to
I don't have source. My system is blocks only. But yes, any value>1023 would do.

Bernd Paysan

unread,
Jun 7, 2015, 7:10:04 PM6/7/15
to
HAA wrote:
>> Block remainder skipping is usually called \\, but Gforth doesn't have
>> it, because very few people use blocks ;-).
>
> Blocks are still in 200x ?

Yes. It always was an optional wordset, but we managed as last-minute
change to drop the "if you have the file wordset, you also must have the
block wordset" from ANS Forth.

So you now can have a standard Forth without block wordset, but the standard
file wordset.

>> Implementation is trivial, though.
>
> Agreed
>
> : \\
> is-current-source-a-text-file? if
> begin refill 0= until
> else ( keyboard, block file or Evaluate)
> source >in ! drop
> then ; immediate

I've a block->file converter, which emits a linefeed character at the end of
each block (in an empty line). I'd then implement \\ to skip until that
linefeed character, so that you simply can convert a block file into a
stream file, and it still works including all \\ comments.

If you don't have a linefeed in your file, it will then end the current
file.

Anton Ertl

unread,
Jun 8, 2015, 3:59:23 AM6/8/15
to
Bernd Paysan <bernd....@gmx.de> writes:
>I've a block->file converter, which emits a linefeed character at the end of
>each block (in an empty line). I'd then implement \\ to skip until that
>linefeed character, so that you simply can convert a block file into a
>stream file, and it still works including all \\ comments.

At least in Unix and Windows, every newline contains a line feed, so
looking for a line feed would just go to the next line. And looking
for two consecutive line feeds would find any empty line.

Do you mean a form feed? That would appear a logical choice for
sectioning a file into blocks or pages.

- 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 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm

Bernd Paysan

unread,
Jun 8, 2015, 11:12:32 AM6/8/15
to
Anton Ertl wrote:

> Bernd Paysan <bernd....@gmx.de> writes:
>>I've a block->file converter, which emits a linefeed character at the end
>>of
>>each block (in an empty line). I'd then implement \\ to skip until that
>>linefeed character, so that you simply can convert a block file into a
>>stream file, and it still works including all \\ comments.
>
> At least in Unix and Windows, every newline contains a line feed, so
> looking for a line feed would just go to the next line. And looking
> for two consecutive line feeds would find any empty line.
>
> Do you mean a form feed? That would appear a logical choice for
> sectioning a file into blocks or pages.

Yes, I meant form feed.

HAA

unread,
Jun 9, 2015, 3:52:00 AM6/9/15
to
Bernd Paysan wrote:
> ...
> BTW: no need to implement it, Gforth already has \\\ which has the same
> effect. It's implemented portably, i.e. it first does the REPOSITION-FILE
> thing, and then a REFILL loop, and finally the POSTPONE \.

POSTPONE \ is logically redundant since the end-of-stream has
already been reached by the REFILLs. The odd implemention will
need it because of the poor spec for REFILL.

REFILL should have been defined the same way as READ-LINE.
When at end-of-stream, REFILL should zero >IN, leave a false flag,
and have SOURCE return an empty string.



HAA

unread,
Jun 9, 2015, 3:53:46 AM6/9/15
to
Bernd Paysan wrote:
> HAA wrote:
> >> Block remainder skipping is usually called \\, but Gforth doesn't have
> >> it, because very few people use blocks ;-).
> >
> > Blocks are still in 200x ?
>
> Yes. It always was an optional wordset, but we managed as last-minute
> change to drop the "if you have the file wordset, you also must have the
> block wordset" from ANS Forth.
>
> So you now can have a standard Forth without block wordset, but the standard
> file wordset.

So if \\ were ever to be standardized it could not ignore blocks :)

> ...
> I've a block->file converter, which emits a linefeed character at the end of
> each block (in an empty line). I'd then implement \\ to skip until that
> linefeed character, so that you simply can convert a block file into a
> stream file, and it still works including all \\ comments.
>
> If you don't have a linefeed in your file, it will then end the current
> file.

What of the LOAD THRU --> etc commands originally present in the block file?
These will require manual conversion before the resulting text file will work.
Dealing with \\ would be least of my concerns.



Bernd Paysan

unread,
Jun 9, 2015, 5:40:03 PM6/9/15
to
HAA wrote:
> What of the LOAD THRU --> etc commands originally present in the block
> file? These will require manual conversion before the resulting text file
> will work. Dealing with \\ would be least of my concerns.

--> does just a refill, and therefor works in the converted file (reads the
next line).

LOAD and THRU have to be edited away, but that's usually just a load screen,
and therefore easy to do (or very hard, if you have a load screen which
contains a lot of LOADs and THRUs ;-).

hughag...@gmail.com

unread,
Jun 9, 2015, 8:11:03 PM6/9/15
to
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.

jo...@planet.nl

unread,
Jun 10, 2015, 7:03:18 AM6/10/15
to
Thank you for the effort.
Meanwhile I got an easy way out in Gforth by using:
' \\\ alias \s
Sorry for the hassle.

Jos

HAA

unread,
Jun 13, 2015, 2:25:48 AM6/13/15
to
Coos Haak wrote:
> Op Fri, 5 Jun 2015 21:36:54 +1000 schreef HAA:
> ...
> >: \\
> > is-current-source-a-text-file? if
> > begin refill 0= until
> > else ( keyboard, block file or Evaluate)
> > source >in ! drop
> > then ; immediate
>
> Too much code.

For miracles you need to look elsewhere

> It's Immediate only because \ and ( are.
> It's not a comment:

You can argue over it with Forth Inc :

\\ ( - )
During an INCLUDE operation, treat anything following this
word as a comment; i.e., anything that follows \\ in a source
file will not be compiled.

> what if you by accident place it in the body of a
> definition. You're still in compile mode.

Same can happen with an unterminated ( or colon definition.
I'm not concerned

> At least use something like ?EXEC.

Ditto





coos

unread,
Jun 13, 2015, 3:46:03 PM6/13/15
to
Op Sat, 13 Jun 2015 16:20:30 +1000 schreef HAA:
In a file, ( may have no terminating ), look it up.

groet Coos

hughag...@gmail.com

unread,
Jun 14, 2015, 1:46:27 AM6/14/15
to
On Friday, June 5, 2015 at 4:40:01 AM UTC-7, HAA wrote:
> Bernd Paysan wrote:
> > Implementation is trivial, though.
>
> Agreed
>
> : \\
> is-current-source-a-text-file? if
> begin refill 0= until
> else ( keyboard, block file or Evaluate)
> source >in ! drop
> then ; immediate
>
> It's Immediate only because \ and ( are.

So how does IS-CURRENT-SOURCE-A-TEXT-FILE work in ANS-Forth? That doesn't look trivial to me.

coos

unread,
Jun 14, 2015, 11:16:02 AM6/14/15
to
Op Sat, 13 Jun 2015 22:46:26 -0700 (PDT) schreef hughag...@gmail.com:
Correction:

SOURCE-ID 0> BLK 0= AND

groet Coos

coos

unread,
Jun 14, 2015, 11:26:03 AM6/14/15
to
Op Sat, 13 Jun 2015 22:46:26 -0700 (PDT) schreef hughag...@gmail.com:

SOURCE-ID 0> BLK 0= OR

groet Coos

hughag...@gmail.com

unread,
Jun 14, 2015, 1:32:28 PM6/14/15
to
Okay, thanks for that information --- I wasn't aware of SOURCE-ID in the file-extension as I had only looked at the core version. BTW: A file-id can be negative, so your 0> doesn't work. Also, BLK is a variable.

Anyway, here is what will get put in the novice package:

: \\ ( -- ) \ comments out the remainder of the file
BLK @ abort" *** \\ doesn't support block files ***"
source-id 0= source-id -1 = or if \ SOURCE-ID is EVALUATE or the console
source >in ! drop
else \ SOURCE-ID is a file-id
begin refill 0= until
then ;

I could make \\ support block files (just store 1024 in >IN should work) but I didn't bother with this because I don't want to take the time to test it.

Alex McDonald

unread,
Jun 16, 2015, 3:51:55 PM6/16/15
to
It's not clear to me what ( should do from the console if there's no
matching ). I assume the comment ends on the same line if it is missing.

Mark Wills

unread,
Jun 17, 2015, 4:06:18 AM6/17/15
to
That's how my system works, yes. More as a side effect of the word WORD
than by design. In a block, a missing ) will cause the rest of the
block to be 'sucked up' by ( but you're not using blocks so I guess
you're okay.

My definition is simply:

; Comments: ( \ & .(
; Allows comments e.g. : 1TO3 ( comment) 1 2 3 ;
; Reads through the TIB until ) is found or end of line
remh data expcth,immed+1
text '( '
rem data docol
data lit,')',word,drop2
data exit

Which translates to:

: (
ascii ) word 2drop ; immediate
( now I can use comments! and stack sigs!)

Mark

coos

unread,
Jun 17, 2015, 10:27:33 AM6/17/15
to
Op Wed, 17 Jun 2015 01:06:16 -0700 (PDT) schreef Mark Wills:
drop
Perhaps you were thinking of
: ( [char] ) parse 2drop ; immediate

> ( now I can use comments! and stack sigs!)
>
> Mark

groet Coos

coos

unread,
Jun 17, 2015, 10:44:03 AM6/17/15
to
Op Wed, 17 Jun 2015 16:15:33 +0200 schreef coos:

> Op Wed, 17 Jun 2015 01:06:16 -0700 (PDT) schreef Mark Wills:
>
<snip>
>>: (
>> ascii ) word 2drop ; immediate
> drop
> Perhaps you were thinking of
>: ( [char] ) parse 2drop ; immediate
>
>> ( now I can use comments! and stack sigs!)
>>
>> Mark
>

Moreover, the version with WORD has a bug:
( )fail
will parse past fail because WORD can't handle NULL strings.
The version with PARSE stops right after ) as is intended.

groet Coos
0 new messages