Current standings: Strawpoll: better name for PARSE-WORD

forth

    Next

  • 1. Use of PICK and ROLL
    Hey.... First, thanks to all who replied concerning the appropriateness of newbie questions on this newsgroup. In Leo Wong's tutorial "Simple Forth" it states: "Forth programmers generally don't use PICK and ROLL much, preferring specific to general solutions, and avoiding the temptation to treat the stack as array" Other than suspecting that PICK and ROLL are not supported by every "flavor" of Forth, I don't understand where the issue is. Could someone please flesh out the above quotation for me, so that I can see the issue? I *do not* question that there is an issue -- I simply can't see it for looking. TIA...
  • 2. Drawing lines in colorForth
    1. how to? amusing myself with colorforth i wanted to draw lines but ... i'll post my code using r_ as red tag and g_ as green tag: r_dl g_100 g_100 g_at g_500 g_500 g_red g_line g_; r_tl g_show g_black g_screen g_tl g_keyboard g_; but running tl it draws an horizontal line from left margin to right margin of screen with a gap inside. 2. where can i find a list with colorforth words? best regards, hd
  • 3. Selling all my FORTH books.
    Selling all my Forth books. I've been retired for several years now and I know I'm not going to do any more programming. I've got a stack of Forth books that I'd like to sell. I'd prefer to sell them all as a lot. Here is what I have: Starting Forth 1st edition, Starting Forth 2nd edition, Dr. Dobbs Toolbook of Forth Vol. 1, Dr. Dobbs Toolbook of Forth Vol. 2, Forth Fundamentals Vol. 1, Forth Fundamentals Vol. 2, two copies of Forth Tools and Applications, Library of Forth Routines and Utilities, Forth Encyclopedia 2nd Edition, F-PC Technical Reference Manual, Mastering Forth, Forth Dimensions Vol V. In addition I'm throwing in Writing VX-REXX Programs, The 8051 Microcontroller Architecture, Programming, and Applications, 8051 Product Directory, and an Analog Devices manual "Practical Design Techniques for Sensor Signal Conditioning. The total weight is about 25 lbs. Anyone interested? Make me an offer that I can't refuse for the lot. I will ship them for the actual shipping costs to be determined when I know where they would be shipped to. I live in Hemet, CA and my phone number is (951) 294-8180. Call me if you are interested. Thanks, Art Horne

Current standings: Strawpoll: better name for PARSE-WORD

Postby anton » Mon, 18 Apr 2005 03:46:27 GMT

 XXXX@XXXXX.COM  (Anton Ertl) writes:

Ok the following names have been proposed and support for them has
been announced:
NextWord (conflict: exists with different meaning in Win32Forth)
TOKEN
  Supported by: Alex McDonald
NAME (existing practice: exists with this meaning in Gforth)
  Supported by: Coos Haak
  Supported by: Albert van der Horst
EXTRACTWORD
EXTRACT-WORD
  Supported by: Ward McFarland
GET-WORD
GET-NAME
GET-TOKEN
PARSE-NAME
  Supported by: Stephen Pelc
  Second choice: Albert van der Horst
  Could live with it: Ward McFarland
PARSE-STREAM

None of the names has had enough open support that I feel comfortable
in using it in an RfD.  Maybe people are not interested enough in such
a word to try to standardize it.  Or people want such a word, but do
care much which name it gets and have therefore not announced support
for any of the names.

My current plan is to shelve this RfD, unless I see some more support
for it.  If anyone else wants to pick it up, you are welcome.

- anton
-- 
M. Anton Ertl   http://www.**--****.com/ 
comp.lang.forth FAQs:  http://www.**--****.com/ 
New standard:  http://www.**--****.com/ 

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby Bernd Paysan » Mon, 18 Apr 2005 04:58:23 GMT



BTW: Recently, I wrote a GDS II generating program, and GDS II has a number
of places where you want simple strings (so you'd use PARSE-WORD or
whatever better name you want). However, I want to make this program fully
scriptable, so I also need a way to pass these strings as such (>STRING,
and >" <text>" for string literals). I used a NEXTNAME-like approach, like
Gforth's NEXTNAME. However, Gforth's NEXTNAME modifies the way headers are
generated, while >STRING changes the way my PARSE-WORD wrapper works.
Instead of parsing, it takes the last string shifted in. In an ad-hoc
fashion, I named the readers <WORD and <LINE (the latter takes the rest of
the line). ATM, >STRING can push only one item, but a generalized version
would be a stack.

My conclusion is that PARSE-WORD is not exactly the right factor, at least
not for this application. And to find a good name is even more difficult,
since all good names apparently are already taken.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
 http://www.**--****.com/ ~paysan/

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby Alex McDonald » Mon, 18 Apr 2005 06:31:27 GMT

Alex McDonald could also support

 PARSE-NAME
  Supported by: Stephen Pelc
  Second choice: Albert van der Horst
  Could live with it: Ward McFarland 

-- 
Regards
Alex McDonald


Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby mhx » Mon, 18 Apr 2005 15:59:33 GMT

 XXXX@XXXXX.COM  (Anton Ertl) wrote Re: Current standings: Strawpoll: better name for PARSE-WORD


In iForth this word would be defined as BL <WORD> , a phrase indeed used
all over the kernel source code. I can live with PARSE-NAME , although
imho BL PARSE-STRING or BL PARSE-WORD better shows what is actually done, 
with negligeable cost.


-marcel


Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby anton » Tue, 19 Apr 2005 03:21:41 GMT

 XXXX@XXXXX.COM  (Marcel Hendrix) writes:

Do you ever use <WORD> with a different delimiter than BL?  If so,
which one and for what?  (I have a hard time imagining that skipping
non-white-space delimiters is useful.)


Thanks, noted.


I have just tried whether TABs work as white space in iforth.  They
do.  It's not clear to me how passing BL as a delimiter shows better
what is actually done than having a word that is specified as using
white space as delimiter.

- anton
-- 
M. Anton Ertl   http://www.**--****.com/ 
comp.lang.forth FAQs:  http://www.**--****.com/ 
New standard:  http://www.**--****.com/ 

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby mhx » Tue, 19 Apr 2005 04:36:18 GMT

XXXX@XXXXX.COM (Anton Ertl) wrote Re: Current standings: Strawpoll: better name for PARSE-WORD



Here are a few.


-- Relatively high-level helper word to compile help messages
: .STATUS" ( "text" -- )
&" <WORD> 2>R
EVAL" OVER = IF DROP "
2R> POSTPONE SLITERAL
EVAL" .STATUSTEXT 0 EXIT ENDIF " ; IMMEDIATE

: 'EVALUATE' ( c-addr u -- ) ( F: -- r )
OVER C@ &' <> IF EVALUATE EXIT ENDIF
1 /STRING S" " $+
&' <WORD> $+ EVALUATE ; PRIVATE

\ Compile a LINE of text
: out~ ( <text~> -- )
'~' <WORD>
POSTPONE SLITERAL
POSTPONE >out ;P IMMEDIATE

: MCI: ( "string" -- )
0 <WORD> MCI-IF
CR ." response> " ?DUP IF TYPE
ELSE DROP ." <null>"
ENDIF ;

-- stack effect must be neutral
: .TICKS" S" :NONAME TICKS-RESET "
'"' <WORD> $+
S" TICKS? ; DUP EXECUTE UD. .( clock ticks elapsed) CP ! " $+
EVALUATE ;

-- Wil Baden's Toolbelt
: LEXEME ( "name" -- str len )
BL <WORD> DUP 1 =
IF DROP C@ <WORD> THEN ;

-- User contribution
: A /OF Airports LOCAL idx-a 1 ENLARGE Airports
/OF locations LOCAL idx-l 1 ENLARGE locations
BL <WORD> idx-a TO Airports:Id
GETNUMBER idx-l TO locations:posx
GETNUMBER idx-l TO locations:posy
BL WORD DROP
CARRET <WORD> idx-a TO Airports:Name
idx-l idx-a TO Airports:Position ;

: BENCHMARK ( name path command name -- )
CREATE ( "name" )
HERE >R 0 , \ filename + path
0 , \ command line to execute
#bench ,
1 +TO #bench
[char] " PARSE 2DROP [char] " <WORD> HERE OVER 1+ ALLOT PACK R@ !
[char] " PARSE 2DROP [char] " <WORD> HERE OVER 1+ ALLOT PACK R> CELL+ !
DOES> DECIMAL EVAL" MARKER ONCE"
@+ COUNT 2DUP INCLUDED
logname logfile PACK DROP OPEN-LOG
CR .~ ********** BENCHMARK: "~ TYPE .~ " run at ~ .TIME$ CR
TICKS-RESET
@+ SWAP @ >R COUNT EVALUATE
TICKS? benchtimes R> 2* 1+ DOUBLE[] 2!
CR CLOSE-LOG
EVAL" ONCE "
EVAL" DEPTH 0<> [IF] .( stack unbalanced!) ABORT [THEN]" ;

-- timemod.frt
: M" ( -- )
>IN @ >R &" <WORD> POSTPONE SLITERAL R> >IN !
S" CR #55 OVER - >S TYPE S> SPACES " EVALUATE
S" CLEAR kk CLEAR tsum" EVALUATE
S" TRIALS 0 DO " EVALUATE
S" TICKS-RESET" EVALUATE
S" n 1+ 1 DO I S>F TO fi " EVALUATE
S" n 1+ 1 DO" EVALUATE
&" <WORD> EVALUATE
S" LOOP" EVALUATE
S" LOOP" EVALUATE
S" TICKS? DROP DUP " EVALUATE
S" I STRIALS >= IF #1000 / 6 .R " EVALUATE
S" ELSE 2DROP 0 " EVALUATE
S" ENDIF +TO tsum " EVALUATE
S" LOOP " EVALUATE
S" tsum n n * TRIALS STRIALS - * " EVALUATE
S" / 8 .R " EVALUATE ; IMMEDIATE

C:\dfwforth\examples\blocks\editor.frt(226): : ?TEXT >S '^' <WORD> DUP \ <a-addr> --- <c-addr> <u>
C:\dfwforth\examples\graphics\gtext.frt(1039): 0 <WORD> \TYPE ;
C:\dfwforth\examples\internet\pmail.frt(130): &" PARSE 2DROP &" <WORD>

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby Coos Haak » Tue, 19 Apr 2005 05:13:38 GMT

Op Sun, 17 Apr 2005 19:36:18 GMT schreef Marcel Hendrix:


I find it hard to believe that '<delmiter> PARSE' would not have worked
here ;-(

Coos
-- 
CHForth, 16 bit DOS
 http://www.**--****.com/ 

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby m_l_g3 » Wed, 20 Apr 2005 00:17:07 GMT




I am strongly opposed to the use of word "token" since we already have
got execution tokens and compiled execution tokens (run-time semantics IIRC),
as well as F-Code tokens.

(To be honest, I define words TOKEN<blablabla> to mean access to the
code being generated).


Sort of conflicts with >NAME NAME> that used to be sort of standard.


Looks like it's important, but cannot be agreed upon.

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby m_l_g3 » Wed, 20 Apr 2005 00:20:40 GMT



I have seen  lot of code doing 0 WORD to parse till EOL.

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby David N. Williams » Wed, 20 Apr 2005 04:46:37 GMT



I regret that the DPANS annex meaning for PARSE-WORD must be
abandoned, because it seems natural to me; but I can live with
PARSE-NAME.

I agree with Michael Gassanenko's implication that it's important
not to leave this unsettled.

What becomes of the status of PARSE-WORD?  I take it that the
meaning in the annex is to be declared nonportable.  With that
meaning off the table, is enough agreement possible that it can
be portable, or should PARSE-WORD be declared unusable for ANS
Forth portable programming?

-- David


Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby anton » Thu, 21 Apr 2005 02:05:59 GMT

"David N. Williams" < XXXX@XXXXX.COM > writes:

It's the same status that it has now: A non-standard word that has two
commonly implemented, conflicting meanings.


It is non-portable.  No need for declarations.


I don't understand this question.


PARSE-WORD is not in ANS Forth, so it obviously cannot be used in ANS
Forth programs.

- anton
-- 
M. Anton Ertl   http://www.**--****.com/ 
comp.lang.forth FAQs:  http://www.**--****.com/ 
New standard:  http://www.**--****.com/ 

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby anton » Thu, 21 Apr 2005 02:10:29 GMT

XXXX@XXXXX.COM (Marcel Hendrix) writes:

PARSE is obviously more appropriate than <WORD> here.


I don't understand that.


Another case for PARSE.


I guess that's supposed to mean "the rest of the line". PARSE would
work equally well here.


Another case for PARSE.


Looks to me like PARSE is more appropriate for the second <WORD> here,
too.


Undocumented, no analysis possible.


That's interesting, because this might be a case where the author
apparently knew about PARSE, and the use of <WORD> with a non-BL
identifier is intentional, not just a bug like in most of the other
cases. But without documentation or usage examples it's hard to tell.

An alternative explanation is that originally there was something else
here, and Marcel introduced <WORD> in his usual way of sprinking
iForthisms over all code he sees:-).


Hmm, I think I'm getting it now: Find the first '"', then the string
we are interested in goes from there to the next '"'. PARSE would be
more appropriate than <WORD> here, too.

Overall, it seems to me that we can divide the usages of <WORD> into
three groups based on the delimiter:

Delimiter BL: Used correctly, BL <WORD> can be replaced with
PARSE-WORD ( -- addr u ).
Delimiter 0: Used correctly, can be replaced with PARSE.
Other delimiters: Bug, should be replaced with PARSE

- 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.complang.tuwien.ac.at/forth/ansforth/forth200x.html

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby mhx » Thu, 21 Apr 2005 04:05:03 GMT

 XXXX@XXXXX.COM  (Anton Ertl) writes Re: Current standings: Strawpoll: better name for PARSE-WORD




[..]

[..]

And more of the same.


I see a pattern. It seems PARSE behaves differently from what I 
thought the Standard described.

What is the exact behavior for the following test cases?

char " PARSE "HELLO" .S
char " PARSE HELLO""" .S
char " PARSE HELLO" .S
char " PARSE    HELLO" .S
char " PARSE"HELLO" .S
char " PARSE """HELLO" .S

char " <WORD> "HELLO" .S
char " <WORD> HELLO""" .S
char " <WORD> HELLO" .S
char " <WORD>    HELLO" .S
char " <WORD>"HELLO" .S
char " <WORD> """HELLO" .S

-marcel


Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby anton » Thu, 21 Apr 2005 17:04:24 GMT

 XXXX@XXXXX.COM  (Marcel Hendrix) writes:

The essential difference between PARSE and <WORD> (i.e., F83's
PARSE-WORD) is that <WORD> skips leading delimiters and PARSE does
not.  And I don't think that skipping leading delimiters is
appropriate in the cases you showed, nor in any case where the
delimiter is not white space.  E.g.,

.STATUS" """a string" \ wrong with PARSE, right with <WORD>.
.STATUS" " DUP \ wrong with <WORD>, right with PARSE

Most users probably expect the first case to be wrong, and the second
case to be right (or at least, they certainly don't expect the
behaviour that <WORD> produces for the second case, i.e., consuming
the rest of the line as parsed string).


I have run these cases through iForth 2.0.257.  Looks like iForth is
doing the right thing for PARSE, and its <WORD> works like F83's
PARSE-WORD.

FORTH> char " PARSE "HELLO" .S 
Error -13 
char " PARSE "HELLO" .S
--------------------^
HELLO" ? 
FORTH> char " PARSE HELLO""" .S 
Error -13 
char " PARSE HELLO""" .S
---------------------^
"" ? 
FORTH> char " PARSE HELLO" .S 
  Data: 136182797 5 ---
System: ---
 Float: --- ok
[2]FORTH> char " PARSE    HELLO" .S 
  Data: 136182797 5 136182797 8 ---
System: ---
 Float: --- ok
[4]FORTH> char " PARSE"HELLO" .S 
Error -13 
char " PARSE"HELLO" .S
-------------------^
PARSE"HELLO" ? 
FORTH> char " PARSE """HELLO" .S 
Error -13 
char " PARSE """HELLO" .S
----------------------^
""HELLO" ? 
FORTH>   ok
FORTH> char " <WORD> "HELLO" .S 
<WORD> is not portable. 
  Data: 136182799 5 ---
System: ---
 Float: --- ok
[2]FORTH> char " <WORD> HELLO""" .S 
<WORD> is not portable. 
Error -13 
char " <WORD> HELLO""" .S
----------------------^
"" ? 
FORTH> char " <WORD> HELLO" .S 
<WORD> is not portable. 
  Data: 136182798 5 ---
System: ---
 Float: --- ok
[2]FORTH> char " <WORD>    HELLO" .S 
<WORD> is not portable. 
  Data: 136182798 5 136182798 8 ---
System: ---
 Float: --- ok
[4]FORTH> char " <WORD>"HELLO" .S 
Error -13 
char " <WORD>"HELLO" .S
--------------------^
<WORD>"HELLO" ? 
FORTH> char " <WORD> """HELLO" .S 
<WORD> is not portable. 
  Data: 136182801 5 ---
System: ---
 Float: --- ok

Running this in Gforth (with ": <word> sword ;") reveals a bug in the
error reporting, but otherwise seems to produce the same results.

- anton
-- 
M. Anton Ertl   http://www.**--****.com/ 
comp.lang.forth FAQs:  http://www.**--****.com/ 
New standard:  http://www.**--****.com/ 

Re: Current standings: Strawpoll: better name for PARSE-WORD

Postby David N. Williams » Sat, 23 Apr 2005 03:09:40 GMT


two

I was certainly unclear.  My brain conflates more often than I
would like, in this case common practise with ANS Forth
portability.

What I was trying to get at was, if the definition of PARSE-WORD
in the annex is eschewed, can the remaining usage justifiably be
called common practise?

-- David

"Eschew the sinister hand, espouse the dexter." --dnw on magnetism




Return to forth

 

Who is online

Users browsing this forum: No registered users and 20 guest