Empty Search Order vs Search Empty Wordlist : Forth
This is a discussion on Empty Search Order vs Search Empty Wordlist within the Forth forums in Programming Languages category; subject: Empty Search Order vs Search Empty Wordlist I am working on a project that requires strings to be EVALUATEd for numerical content, and wanted to find the simplest way to do it. We know that when a string does not match a name in the search order, an attempt is made to convert it to a number in the current base. I've found two ways to ensure the string doesn't match a name: 1) put only an empty wordlist in the search order or 2) use an empty search order (see 16.6.1.2197 SET-ORDER). Using an empty search order is ...
| Forth Forth programming language |
![]() |
| | LinkBack | Thread Tools |
|
#1
| |||
| |||
| Empty Search Order vs Search Empty Wordlist I am working on a project that requires strings to be EVALUATEd for numerical content, and wanted to find the simplest way to do it. We know that when a string does not match a name in the search order, an attempt is made to convert it to a number in the current base. I've found two ways to ensure the string doesn't match a name: 1) put only an empty wordlist in the search order or 2) use an empty search order (see 16.6.1.2197 SET-ORDER). Using an empty search order is simplest. The question: Is an empty search order valid? The results: Search Empty Wordlist Empty Search Order swiftforth 3.0.8 PC works works win32forth 6.12 PC works works vfx (MPE) 4.02 PC works works eforth 20070916 PC works works gforth 0.6.9 PC works FAILS gforth 0.6.9 Mac works FAILS -- Bill Muench Santa Cruz, California \ ============================================================== DECIMAL \ a simple way to save and restore the search order CREATE ORDER[] 0 , 16 CELLS ALLOT ( ANS minimum = 8 ) : SAVE-ORDER ( -- ) ( not nestable ) ORDER[] @ ABORT" save-order?" GET-ORDER DUP 1+ 0 DO I CELLS ORDER[] + ! LOOP ; : RESTORE-ORDER ( -- ) ( not nestable ) 0 ORDER[] 2DUP @ DUP 0= ABORT" restore-order?" DO I CELLS ORDER[] + @ -1 +LOOP SET-ORDER ( 0 a ) ! ; \ ============================================================== \ test: Search Empty Wordlist WORDLIST CONSTANT EMPTY-WORDLIST : SEW ( 'ccc' -- n|d ) ( Search Empty Wordlist ) SAVE-ORDER EMPTY-WORDLIST 1 SET-ORDER ( search empty wordlist ) PARSE-WORD ['] EVALUATE CATCH ( stack: error | n|d 0 ) RESTORE-ORDER ( restore order ) ABORT" number?" ; ( before error control ) decimal SEW 1234 decimal . \ should display 1234 hex SEW 04D2 decimal . \ should display 1234 decimal SEW 1234. decimal D. \ should display 1234 hex SEW 04D2. decimal D. \ should display 1234 \ ============================================================== \ test: Empty Search Order : ESO ( 'ccc' -- n|d ) ( Empty Search Order ) SAVE-ORDER 0 SET-ORDER ( empty search order ) PARSE-WORD ['] EVALUATE CATCH ( stack: error | n|d 0 ) RESTORE-ORDER ( restore order ) ABORT" number?" ; ( before error control ) decimal ESO 1234 decimal . \ should display 1234 hex ESO 04D2 decimal . \ should display 1234 decimal ESO 1234. decimal D. \ should display 1234 hex ESO 04D2. decimal D. \ should display 1234 |
|
#2
| |||
| |||
| Bill <bill@domain.invalid> writes: >2) use an empty search order (see 16.6.1.2197 SET-ORDER). >Using an empty search order is simplest. > > >The question: Is an empty search order valid? Yes. >The results: Search Empty Wordlist Empty Search Order > gforth 0.6.9 PC works FAILS > gforth 0.6.9 Mac works FAILS That's a bug. I am currently looking into fixing it (unfortunately, there are several bugs lurking in that corner). - 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 2007: http://www.complang.tuwien.ac.at/anton/euroforth2007/ |
|
#3
| |||
| |||
| Bill <bill@domain.invalid> writes Re: Empty Search Order vs Search Empty Wordlist [..] > subject: > Empty Search Order vs Search Empty Wordlist [..] > The question: Is an empty search order valid? [..] > The results: Search Empty Wordlist Empty Search Order > swiftforth 3.0.8 PC works works > win32forth 6.12 PC works works > vfx (MPE) 4.02 PC works works > eforth 20070916 PC works works > gforth 0.6.9 PC works FAILS > gforth 0.6.9 Mac works FAILS iForth 2.1.2559 PC works works But only after adding: : PARSE-WORD ( -- c-addr u ) BL <WORD> ; -marcel |
|
#4
| |||
| |||
| In article <25913633133560@frunobulax.edu>, mhx@iae.nl (Marcel Hendrix) wrote: > Bill <bill@domain.invalid> writes Re: Empty Search Order vs Search Empty > Wordlist > [..] > > subject: > > Empty Search Order vs Search Empty Wordlist > [..] > > The question: Is an empty search order valid? > [..] > > > The results: Search Empty Wordlist Empty Search Order > > swiftforth 3.0.8 PC works works > > win32forth 6.12 PC works works > > vfx (MPE) 4.02 PC works works > > eforth 20070916 PC works works > > gforth 0.6.9 PC works FAILS > > gforth 0.6.9 Mac works FAILS > > iForth 2.1.2559 PC works works > > But only after adding: > > : PARSE-WORD ( -- c-addr u ) BL <WORD> ; > > -marcel Thank you, I will add iForth to my list. -- Bill Muench Santa Cruz, California |
|
#5
| |||
| |||
| Op Sun, 21 Oct 2007 17:32:51 -0700 schreef Bill: <snip> I will look into your proposal, but first my _reentrant_ solution: > CREATE ORDER[] 0 , 16 CELLS ALLOT ( ANS minimum = 8 ) > > : SAVE-ORDER ( -- ) ( not nestable ) > ORDER[] @ ABORT" save-order?" > GET-ORDER DUP 1+ 0 DO I CELLS ORDER[] + ! LOOP ; > \ Push n+1 elements on the return stack. : N>R ( S: xn .. x1 n -- ) ( R: -- xn .. x1 n ) DUP BEGIN DUP WHILE ROT R> SWAP >R >R 1- REPEAT DROP R> SWAP >R >R ; > : RESTORE-ORDER ( -- ) ( not nestable ) > 0 ORDER[] 2DUP @ DUP 0= ABORT" restore-order?" > DO I CELLS ORDER[] + @ -1 +LOOP SET-ORDER ( 0 a ) ! ; > \ Pop n+1 elements from the return stack. : NR> ( S: -- xn .. x1 n ) ( R: xn .. x1 n -- ) R> R> SWAP >R DUP BEGIN DUP WHILE R> R> SWAP >R -ROT 1- REPEAT DROP ; > \ ============================================================== > \ test: Search Empty Wordlist > > WORDLIST CONSTANT EMPTY-WORDLIST > > : SEW ( 'ccc' -- n|d ) ( Search Empty Wordlist ) > SAVE-ORDER > EMPTY-WORDLIST 1 SET-ORDER ( search empty wordlist ) > PARSE-WORD ['] EVALUATE CATCH ( stack: error | n|d 0 ) > RESTORE-ORDER ( restore order ) > ABORT" number?" ; ( before error control ) > : SEW GET-ORDER N>R .... NR> SET-ORDER ; I would use PARSE-WORD and >NUMBER or some other string to number conversion words instead of the convoluted interpretation with EVALUATE. That way the search order doesn't matter at all. -- Coos CHForth, 16 bit DOS applications http://home.hccnet.nl/j.j.haak/forth.html |
|
#6
| |||
| |||
| In article <1xbr6by1lajl.zscvylrx24d6$.dlg@40tude.net>, Coos Haak <chforth@hccnet.nl> wrote: > I would use PARSE-WORD and >NUMBER or some other string to number > conversion words instead of the convoluted interpretation with EVALUATE. > That way the search order doesn't matter at all. Subject: Empty Search Order vs Search Empty Wordlist Number conversion is NOT the focus of this thread. It is whether: 0 SET-ORDER is functionally equivalent to: EMPTY-WORDLIST 1 SET-ORDER So far, it seems the answer is YES. -- Bill Muench Santa Cruz, California |
|
#7
| |||
| |||
| Op Mon, 22 Oct 2007 12:20:21 -0700 schreef Bill: > In article <1xbr6by1lajl.zscvylrx24d6$.dlg@40tude.net>, > Coos Haak <chforth@hccnet.nl> wrote: > >> I would use PARSE-WORD and >NUMBER or some other string to number >> conversion words instead of the convoluted interpretation with EVALUATE. >> That way the search order doesn't matter at all. > > Subject: Empty Search Order vs Search Empty Wordlist > > Number conversion is NOT the focus of this thread. > > It is whether: > > 0 SET-ORDER > > is functionally equivalent to: > > EMPTY-WORDLIST 1 SET-ORDER > > So far, it seems the answer is YES. In that case, CHForth the answer is YES too ;-) -- Coos CHForth, 16 bit DOS applications http://home.hccnet.nl/j.j.haak/forth.html |
|
#8
| |||
| |||
| In article <1ds7hqo9zixiy$.114tbu86bb65v$.dlg@40tude.net>, Coos Haak <chforth@hccnet.nl> wrote: > Op Mon, 22 Oct 2007 12:20:21 -0700 schreef Bill: > > > In article <1xbr6by1lajl.zscvylrx24d6$.dlg@40tude.net>, > > Coos Haak <chforth@hccnet.nl> wrote: > > > >> I would use PARSE-WORD and >NUMBER or some other string to number > >> conversion words instead of the convoluted interpretation with EVALUATE. > >> That way the search order doesn't matter at all. > > > > Subject: Empty Search Order vs Search Empty Wordlist > > > > Number conversion is NOT the focus of this thread. > > > > It is whether: > > > > 0 SET-ORDER > > > > is functionally equivalent to: > > > > EMPTY-WORDLIST 1 SET-ORDER > > > > So far, it seems the answer is YES. > > In that case, CHForth the answer is YES too ;-) Thank you, another on the list for YES. What is the version number of CHForth? -- Bill Muench Santa Cruz |
|
#9
| |||
| |||
| In article <1xbr6by1lajl.zscvylrx24d6$.dlg@40tude.net>, Coos Haak <chforth@hccnet.nl> wrote: > Op Sun, 21 Oct 2007 17:32:51 -0700 schreef Bill: > > <snip> > > I will look into your proposal, but first my _reentrant_ solution: Yes, your _reentrant_ solution works well WITHIN the same word. I submitted the simple non-reentrant version because it was also used to span two words, where there is no need to nest. : m] ... restore-order ... ; : [m ... save-order ... ; Then... I realized that no parameters are ever passed thru [m so the words have been simplified. : m] ( wid*n n u -- ) ?csp csp ! ( nested stack check ) set-order ; immediate ( end macro segment ) : [m ( -- wid*n n u ) ( start macro segment, end with m] ) get-order csp @ !csp ( nested stack check ) fail-wordlist m4-wordlist 2 set-order ; immediate -- Bill Muench Santa Cruz > > CREATE ORDER[] 0 , 16 CELLS ALLOT ( ANS minimum = 8 ) > > > > : SAVE-ORDER ( -- ) ( not nestable ) > > ORDER[] @ ABORT" save-order?" > > GET-ORDER DUP 1+ 0 DO I CELLS ORDER[] + ! LOOP ; > > > \ Push n+1 elements on the return stack. > : N>R ( S: xn .. x1 n -- ) ( R: -- xn .. x1 n ) > DUP > BEGIN DUP > WHILE ROT R> SWAP >R >R 1- > REPEAT > DROP R> SWAP >R >R > ; > > > : RESTORE-ORDER ( -- ) ( not nestable ) > > 0 ORDER[] 2DUP @ DUP 0= ABORT" restore-order?" > > DO I CELLS ORDER[] + @ -1 +LOOP SET-ORDER ( 0 a ) ! ; > > > \ Pop n+1 elements from the return stack. > : NR> ( S: -- xn .. x1 n ) ( R: xn .. x1 n -- ) > R> R> SWAP >R DUP > BEGIN DUP > WHILE R> R> SWAP >R -ROT 1- > REPEAT > DROP > ; > > > \ ============================================================== > > \ test: Search Empty Wordlist > > > > WORDLIST CONSTANT EMPTY-WORDLIST > > > > : SEW ( 'ccc' -- n|d ) ( Search Empty Wordlist ) > > SAVE-ORDER > > EMPTY-WORDLIST 1 SET-ORDER ( search empty wordlist ) > > PARSE-WORD ['] EVALUATE CATCH ( stack: error | n|d 0 ) > > RESTORE-ORDER ( restore order ) > > ABORT" number?" ; ( before error control ) > > > : SEW > GET-ORDER N>R > ... > NR> SET-ORDER > ; > > I would use PARSE-WORD and >NUMBER or some other string to number > conversion words instead of the convoluted interpretation with EVALUATE. > That way the search order doesn't matter at all. |
|
#10
| |||
| |||
| anton@mips.complang.tuwien.ac.at (Anton Ertl) writes: >Bill <bill@domain.invalid> writes: >>The results: Search Empty Wordlist Empty Search Order >> gforth 0.6.9 PC works FAILS >> gforth 0.6.9 Mac works FAILS > >That's a bug. I am currently looking into fixing it (unfortunately, >there are several bugs lurking in that corner). Fixed in the CVS now. - 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 2007: http://www.complang.tuwien.ac.at/anton/euroforth2007/ |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search Query Returns Empty Pages in MOSS 2007 | usenet | Sharepoint | 0 | 10-02-2007 07:48 AM |
| empty titles, empty subjects and empty body in PINE | usenet | Pine | 4 | 06-07-2007 03:52 AM |
| Characterization field empty in search results | usenet | Inetserver | 4 | 01-20-2005 12:53 PM |
| Non Empty Behaviour -- IsEmpty() -- Non Empty Clause | usenet | XML SOAP | 0 | 08-13-2004 06:32 PM |
| Re: Empty Search Results | usenet | Inetserver | 0 | 01-05-2004 10:13 AM |
All times are GMT -5. The time now is 01:04 AM.



