Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #37726 > unrolled thread
| Started by | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| First post | 2015-03-29 12:43 +0000 |
| Last post | 2015-04-04 11:25 -0700 |
| Articles | 20 on this page of 80 — 21 participants |
Back to article view | Back to comp.lang.forth
Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-03-29 12:43 +0000
Importing from wordlists. Mark Wills <markwills1970@gmail.com> - 2015-03-29 06:15 -0700
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-03-29 15:11 +0000
Re: Importing from wordlists. hughaguilar96@gmail.com - 2015-03-29 09:14 -0700
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-03-29 19:52 +0000
Re: Importing from wordlists. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-03-30 12:39 +0000
Re: Importing from wordlists. Mark Wills <markwills1970@gmail.com> - 2015-03-30 09:09 -0700
Re: Importing from wordlists. stephen@mpeforth.com (Stephen Pelc) - 2015-03-30 16:42 +0000
Re: Importing from wordlists. hughaguilar96@gmail.com - 2015-03-30 17:55 -0700
Re: Importing from wordlists. Mark Wills <markwills1970@gmail.com> - 2015-04-02 05:41 -0700
Re: Importing from wordlists. "HAA" <someone@microsoft.com> - 2015-03-31 13:26 +1000
Re: Importing from wordlists. hughaguilar96@gmail.com - 2015-03-30 19:54 -0700
Re: Importing from wordlists. Mark Wills <markwills1970@gmail.com> - 2015-03-31 02:23 -0700
Re: Importing from wordlists. Lars Brinkhoff <lars.spam@nocrew.org> - 2015-03-31 12:02 +0200
Re: Importing from wordlists. Mark Wills <markwills1970@gmail.com> - 2015-03-31 07:41 -0700
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-03-31 16:36 +0100
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-03-31 16:52 +0000
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-03-31 18:33 +0100
Re: Importing from wordlists. JennyB <jennybrien@googlemail.com> - 2015-03-31 15:25 -0700
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-01 00:59 +0000
Re: Importing from wordlists. JennyB <jennybrien@googlemail.com> - 2015-04-01 08:05 -0700
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-01 15:25 +0000
Re: Importing from wordlists. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-01 15:58 +0000
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-04-01 15:57 +0100
Re: Importing from wordlists. Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-03-31 23:58 +0100
Re: Importing from wordlists. Bernd Paysan <bernd.paysan@gmx.de> - 2015-04-01 02:00 +0200
Re: Importing from wordlists. hughaguilar96@gmail.com - 2015-03-31 18:48 -0700
Re: Importing from wordlists. Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-04-01 08:03 +0100
Re: Importing from wordlists. Bernd Paysan <bernd.paysan@gmx.de> - 2015-04-01 16:38 +0200
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-04-01 15:54 +0100
Re: Importing from wordlists. Bernd Paysan <bernd.paysan@gmx.de> - 2015-04-01 17:41 +0200
Re: Importing from wordlists. Bernd Paysan <bernd.paysan@gmx.de> - 2015-04-01 18:24 +0200
Re: Importing from wordlists. Bernd Paysan <bernd.paysan@gmx.de> - 2015-04-02 05:27 +0200
Re: Importing from wordlists. Coos Haak <chforth@hccnet.nl> - 2015-04-02 12:38 +0200
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-04-02 15:45 +0100
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-04-02 17:25 +0100
Re: Importing from wordlists. Bernd Paysan <bernd.paysan@gmx.de> - 2015-04-03 02:00 +0200
Re: Importing from wordlists. Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-04-03 20:49 +0100
Re: Importing from wordlists. "Elizabeth D. Rather" <erather@forth.com> - 2015-04-03 11:08 -1000
Re: Importing from wordlists. Paul Rubin <no.email@nospam.invalid> - 2015-04-03 14:14 -0700
Re: Importing from wordlists. franck.bensusan@gmail.com - 2015-04-04 02:47 -0700
Re: Importing from wordlists. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-03 21:37 +0000
Re: Importing from wordlists. "Elizabeth D. Rather" <erather@forth.com> - 2015-04-03 14:05 -1000
Re: Importing from wordlists. Bernd Paysan <bernd.paysan@gmx.de> - 2015-04-04 05:14 +0200
Re: Importing from wordlists. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-04 14:07 +0000
Re: Importing from wordlists. Paul Rubin <no.email@nospam.invalid> - 2015-04-04 14:02 -0700
Re: Importing from wordlists. Melzzzzz <mel@zzzzz.com> - 2015-04-05 00:36 +0200
Re: Importing from wordlists. Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2015-04-04 04:35 +0200
Re: Importing from wordlists. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-04 13:30 +0000
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-04 16:38 +0000
Re: Importing from wordlists. Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2015-04-04 16:48 +0200
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-04-03 23:49 +0100
Re: Importing from wordlists. "Elizabeth D. Rather" <erather@forth.com> - 2015-04-03 14:09 -1000
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-04-04 20:30 +0100
Re: Importing from wordlists. hughaguilar96@gmail.com - 2015-04-04 13:29 -0700
Re: Importing from wordlists. Johan Kotlinski <kotlinski@gmail.com> - 2015-04-03 23:57 -0700
Re: Importing from wordlists. "Elizabeth D. Rather" <erather@forth.com> - 2015-04-03 21:35 -1000
Re: Importing from wordlists. krishna.myneni@ccreweb.org - 2015-04-04 10:00 -0700
Re: Importing from wordlists. Melzzzzz <mel@zzzzz.com> - 2015-04-04 19:08 +0200
Re: Importing from wordlists. Coos Haak <chforth@hccnet.nl> - 2015-04-02 22:45 +0200
Re: Importing from wordlists. Bernd Paysan <bernd.paysan@gmx.de> - 2015-04-03 02:08 +0200
Re: Importing from wordlists. Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-04-02 20:59 +0100
Re: Importing from wordlists. Bernd Paysan <bernd.paysan@gmx.de> - 2015-04-03 02:03 +0200
Re: Importing from wordlists. Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-04-03 20:52 +0100
Re: Importing from wordlists. Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-04-09 12:39 +0100
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-01 15:03 +0000
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-01 01:10 +0000
Re: Importing from wordlists. Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-04-01 07:32 +0100
Re: Importing from wordlists. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-01 07:52 +0000
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-01 10:39 +0000
SYNONYM (wase: Importing from wordlists.) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-01 11:29 +0000
Re: SYNONYM (wase: Importing from wordlists.) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-01 15:08 +0000
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-04-01 15:49 +0100
Re: Importing from wordlists. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-01 17:12 +0000
Re: Importing from wordlists. "Alex McDonald" <blog@rivadpm.com> - 2015-04-01 18:45 +0100
Re: Importing from wordlists. Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-04-01 20:43 +0100
Re: Importing from wordlists. mhx@iae.nl (Marcel Hendrix) - 2015-04-04 09:53 +0200
Re: Importing from wordlists. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-04-04 14:20 +0000
Re: Importing from wordlists. albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-04 17:10 +0000
Re: Importing from wordlists. mhx@iae.nl - 2015-04-04 11:25 -0700
Page 1 of 4 [1] 2 3 4 Next page →
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2015-03-29 12:43 +0000 |
| Subject | Importing from wordlists. |
| Message-ID | <5517f359$0$23216$e4fe514c@dreader34.news.xs4all.nl> |
Suppose I have a wordlist with a word that I want to add to the current wordlist, without having that whole list in the searchorder. In Python e.g. we have from math import sin This means that without attaching the whole math library we can use the sin function. In Forth I want this to be 1. math is a named wordlist. It pushes (called namespace to avoid confusion with non-pushing "also-ing" namelists that are often called vocabularies.) 2. using a word IMPORT 3. Defining a copy in current wordlist. We then get : math IMPORT sin With the right building blocks it is short: : IMPORT SAVE NAME RESTORE FOUND ALIAS PREVIOUS ; SAVE NAME RESTORE is ciforth idiom . It gets a name from the input stream, without advancing the parse pointer. (It is a slight level of abstraction above >IN that deals with addresses and single characters.) Searching only the top of the searchorder would go in ciforth like this : IMPORT SAVE NAME RESTORE CONTEXT (FIND) NIP NIP ALIAS PREVIOUS ; Other Forth's have probably equally easy means. Having it portable is not so easy. As an exercise try to do the last with SYNONYM >IN SEARCH-WORDLIST and GET-ORDER. A parsing version i would dislike: IMPORT math sin but it is not hard : DSSWAP ROT ROT ; : IMPORT NAME FOUND >WID SAVE NAME RESTORE DSSWAP (FIND) ALIAS ; I think it shows that ALIAS ( xt "name" -- ) is superior to SYNONYM ( "name" "name" -- ). I gravitate to opinion that only names of to-be-defined words should be got from the input stream. With SYNONYM things becomes extremely ugly, because we need NAME twice. Making a synonym for a word from a wordlist that is directly searched with SEARCH-WORDLIST becomes nearly impossible. (Thanks to Anton Ertl, who made me aware that having CONTEXT different from CURRENT makes this easy.) 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] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-03-29 06:15 -0700 |
| Message-ID | <68f7eeb0-74f7-4385-8e2a-7503ea9d22f0@googlegroups.com> |
| In reply to | #37726 |
Switch to the source wordlist. Tick the desired word. Switch to the target wordlist. Write a deferred definition. Use IS to load the deferred word. Simple.
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2015-03-29 15:11 +0000 |
| Message-ID | <5518161a$0$2981$e4fe514c@dreader35.news.xs4all.nl> |
| In reply to | #37727 |
In article <68f7eeb0-74f7-4385-8e2a-7503ea9d22f0@googlegroups.com>, Mark Wills <markwills1970@gmail.com> wrote: >Switch to the source wordlist. >Tick the desired word. >Switch to the target wordlist. >Write a deferred definition. >Use IS to load the deferred word. > >Simple. From a recent euler problem (I actually use WANT but let's pretend I use facilities in namespaces. All words in namespace/ccc.frt are in a namespace called ccc. ) " INCLUDE namespace/standard.frt INCLUDE namespace/mhx.frt INCLUDE namespace/oo.frt INCLUDE namespace/bits.frt INCLUDE namespace/text.frt INCLUDE namespace/arithmetic.frt standard IMPORT ALIAS standard IMPORT <= standard IMPORT -scripting- mhx IMPORT $-PREFIX text IMPORT .FORMAT oo IMPORT class bits IMPORT #BITS arithmetic IMPORT x^x " How would that look in your book? 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 | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-03-29 09:14 -0700 |
| Message-ID | <a1ce3ea4-2784-43ce-a752-fead6ef02621@googlegroups.com> |
| In reply to | #37727 |
On Sunday, March 29, 2015 at 6:15:39 AM UTC-7, Mark Wills wrote: > Switch to the source wordlist. > Tick the desired word. > Switch to the target wordlist. > Write a deferred definition. > Use IS to load the deferred word. > > Simple. Mark is right --- this is simple. If you use :NAME from the novice-package, it is even simpler. If you don't mind having a state-smart word, you can make it a macro so it is just as fast as the original word --- actually, if you don't know if your original word was IMMEDIATE or not, then you should just make it a macro and get a state-smart word whether the original was state-smart or not.
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2015-03-29 19:52 +0000 |
| Message-ID | <551857fe$0$21228$e4fe514c@dreader37.news.xs4all.nl> |
| In reply to | #37729 |
In article <a1ce3ea4-2784-43ce-a752-fead6ef02621@googlegroups.com>, <hughaguilar96@gmail.com> wrote: >On Sunday, March 29, 2015 at 6:15:39 AM UTC-7, Mark Wills wrote: >> Switch to the source wordlist. >> Tick the desired word. >> Switch to the target wordlist. >> Write a deferred definition. >> Use IS to load the deferred word. >> >> Simple. > >Mark is right --- this is simple. > >If you use :NAME from the novice-package, it is even simpler. > >If you don't mind having a state-smart word, you can make it a macro so >it is just as fast as the original word --- actually, if you don't know >if your original word was IMMEDIATE or not, then you should just make it >a macro and get a state-smart word whether the original was state-smart >or not. I consider it a defect if a synonym or alias doesn't inherit the properties of its origin, like being IMMEDIATE, a PREFIX, being marked as an ISO word, being compile-only or whatever. 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 | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-03-30 12:39 +0000 |
| Message-ID | <2015Mar30.143920@mips.complang.tuwien.ac.at> |
| In reply to | #37734 |
albert@spenarnc.xs4all.nl (Albert van der Horst) writes:
>I consider it a defect if a synonym or alias doesn't inherit the
>properties of its origin, like being IMMEDIATE, a PREFIX, being
>marked as an ISO word, being compile-only or whatever.
For SYNONYM, the new word certainly should have the same compilation
and interpretation semantics (and consequently, the same immediacy) as
the old one. For ALIAS, there are Forth systems (such as Gforth
<=0.7) where xts represent only the execution/interpretation semantics
and nothing else, and inheriting immediacy through ALIAS is therefore
impossible (and also may be unwanted); we standardized SYNONYM rather
than ALIAS for this reason.
- 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 2014: http://www.euroforth.org/ef14/
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-03-30 09:09 -0700 |
| Message-ID | <8a687955-7490-4a69-b1fa-b32a703aaf4e@googlegroups.com> |
| In reply to | #37754 |
On my 16-bit system IS correctly sets the deferred word to immediate/not immediate. AFAIK carnal knowledge is required as there is no mechanism in ANS to determine a word's immediacy. That might be something we can improve on in the future, though it's a feature that is probably seldom needed.
[toc] | [prev] | [next] | [standalone]
| From | stephen@mpeforth.com (Stephen Pelc) |
|---|---|
| Date | 2015-03-30 16:42 +0000 |
| Message-ID | <55197c8b.277842679@news.eternal-september.org> |
| In reply to | #37761 |
On Mon, 30 Mar 2015 09:09:20 -0700 (PDT), Mark Wills <markwills1970@gmail.com> wrote: >On my 16-bit system IS correctly sets the deferred word to immediate/not im= >mediate. AFAIK carnal knowledge is required as there is no mechanism in ANS= > to determine a word's immediacy. That might be something we can improve on= > in the future, though it's a feature that is probably seldom needed. Far better would be to remove IMMEDIATE altogether except as a legacy option, and to solve the setting of separate compilation and interpretation behaviours. Stephen -- Stephen Pelc, stephenXXX@mpeforth.com MicroProcessor Engineering Ltd - More Real, Less Time 133 Hill Lane, Southampton SO15 5AF, England tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 web: http://www.mpeforth.com - free VFX Forth downloads
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-03-30 17:55 -0700 |
| Message-ID | <af684eb5-1467-4141-98c1-6f3eb3364fa6@googlegroups.com> |
| In reply to | #37761 |
On Monday, March 30, 2015 at 9:09:21 AM UTC-7, Mark Wills wrote: > On my 16-bit system IS correctly sets the deferred word to immediate/not immediate. AFAIK carnal knowledge is required as there is no mechanism in ANS to determine a word's immediacy. That might be something we can improve on in the future, though it's a feature that is probably seldom needed. FIND in ANS-Forth tells you if the word is immediate or not. IIRC, Forth-83 was the same. See 6.1.1550 in the ANS-Forth document: ( c-addr -- c-addr 0 | xt 1 | xt -1 ) Find the definition named in the counted string at c-addr. If the definition is not found, return c-addr and zero. If the definition is found, return its execution token xt. If the definition is immediate, also return one (1), otherwise also return minus-one (-1). For a given string, the values returned by FIND while compiling may differ from those returned while not compiling.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-04-02 05:41 -0700 |
| Message-ID | <c4ec05b5-3027-4b49-9803-0b0636b77c71@googlegroups.com> |
| In reply to | #37767 |
On Tuesday, 31 March 2015 01:55:03 UTC+1, hughag...@gmail.com wrote: > FIND in ANS-Forth tells you if the word is immediate or not. IIRC, Forth-83 was the same. See 6.1.1550 in the ANS-Forth document: Doh! Of course it does! Sorry. Blonde moment ;-)
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2015-03-31 13:26 +1000 |
| Message-ID | <mfd0m0$b4k$1@speranza.aioe.org> |
| In reply to | #37754 |
Anton Ertl wrote: > ... > we standardized SYNONYM rather > than ALIAS for this reason. SYNONYM has known flaws. It was chosen because it was supported.
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-03-30 19:54 -0700 |
| Message-ID | <e7fdd6c6-dffa-4999-85cd-5d97a080b3c2@googlegroups.com> |
| In reply to | #37768 |
On Monday, March 30, 2015 at 7:27:22 PM UTC-7, HAA wrote: > Anton Ertl wrote: > > ... > > we standardized SYNONYM rather > > than ALIAS for this reason. > > SYNONYM has known flaws. It was chosen because it was supported. What are the known flaws of SYNONYM ? Also, what is the definition of SYNONYM ?
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-03-31 02:23 -0700 |
| Message-ID | <0165a96b-3372-4a43-8e77-045994fb5934@googlegroups.com> |
| In reply to | #37769 |
On Tuesday, 31 March 2015 03:54:02 UTC+1, hughag...@gmail.com wrote:
> On Monday, March 30, 2015 at 7:27:22 PM UTC-7, HAA wrote:
> > Anton Ertl wrote:
> > > ...
> > > we standardized SYNONYM rather
> > > than ALIAS for this reason.
> >
> > SYNONYM has known flaws. It was chosen because it was supported.
>
> What are the known flaws of SYNONYM ? Also, what is the definition of SYNONYM ?
Not sure what the flaws are. Here's my version of it:
--BLOCK-00046---------
: SYNONYM
CREATE BL WORD FIND DUP IF
SWAP , IMMEDIATE 1+ IF
DOES> @ EXECUTE
ELSE
DOES> STATE @ IF
@ ,
ELSE
@ EXECUTE
THEN
THEN
ELSE
TRUE ABORT" Word not found"
THEN ;
.( SYNONYM loaded.) .( Usage: SYNONYM NewWord OldWord)
Long time since I wrote this code. I just checked it handles
immediate words okay and it seems fine:
: FOO ." FOO! " ; IMMEDIATE
SYNONYM BAR FOO
: TEST 1 2 BAR 3 ;
FOO!
TEST .S
1 2 3 <--TOP OK:3
[toc] | [prev] | [next] | [standalone]
| From | Lars Brinkhoff <lars.spam@nocrew.org> |
|---|---|
| Date | 2015-03-31 12:02 +0200 |
| Message-ID | <85twx132om.fsf@junk.nocrew.org> |
| In reply to | #37773 |
Mark Wills <markwills1970@gmail.com> writes:
> Not sure what the flaws are. Here's my version of it:
>
> --BLOCK-00046---------
> : SYNONYM
> CREATE BL WORD FIND DUP IF
> SWAP , IMMEDIATE 1+ IF
> DOES> @ EXECUTE
> ELSE
> DOES> STATE @ IF
> @ ,
> ELSE
> @ EXECUTE
> THEN
> THEN
> ELSE
> TRUE ABORT" Word not found"
> THEN ;
Here are some more tests you can try:
\ Test that SYNONYM works.
synonym plus +
synonym comment \
synonym endif then
synonym assign to
: ?fail <> abort" FAIL" ;
0 value x
.( Test interpretation: )
1 2 plus assign x comment foo
x 3 ?fail
.( PASS ) cr
.( Test compilation: )
: foo 3 4 5 if plus assign x endif comment ;
;
foo x 7 ?fail
.( PASS ) cr
.( Test postpone: )
: bar postpone if
postpone plus
postpone assign
postpone endif
postpone comment ; immediate
: baz 6 7 8 bar x ;
;
baz x 13 ?fail
.( PASS ) cr
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-03-31 07:41 -0700 |
| Message-ID | <b5867e85-c3b2-43b8-92d2-b3b0ef55e11c@googlegroups.com> |
| In reply to | #37774 |
On Tuesday, 31 March 2015 11:02:08 UTC+1, Lars Brinkhoff wrote: > Mark Wills <> writes: > > Not sure what the flaws are. Here's my version of it: > > > > --BLOCK-00046--------- > > : SYNONYM > > CREATE BL WORD FIND DUP IF > > SWAP , IMMEDIATE 1+ IF > > DOES> @ EXECUTE > > ELSE > > DOES> STATE @ IF > > @ , > > ELSE > > @ EXECUTE > > THEN > > THEN > > ELSE > > TRUE ABORT" Word not found" > > THEN ; > > Here are some more tests you can try: > > > \ Test that SYNONYM works. > > synonym plus + > synonym comment \ > synonym endif then > synonym assign to > > : ?fail <> abort" FAIL" ; > 0 value x > > .( Test interpretation: ) > 1 2 plus assign x comment foo > x 3 ?fail > .( PASS ) cr > > .( Test compilation: ) > : foo 3 4 5 if plus assign x endif comment ; > ; > foo x 7 ?fail > .( PASS ) cr > > .( Test postpone: ) > : bar postpone if > postpone plus > postpone assign > postpone endif > postpone comment ; immediate > : baz 6 7 8 bar x ; > ; > baz x 13 ?fail > .( PASS ) cr Thanks for that Lars. I tested it against your code. All passed ;-)
[toc] | [prev] | [next] | [standalone]
| From | "Alex McDonald" <blog@rivadpm.com> |
|---|---|
| Date | 2015-03-31 16:36 +0100 |
| Message-ID | <mfeess$7d9$1@dont-email.me> |
| In reply to | #37778 |
on 31/03/2015 15:41:02, Mark Wills wrote: > On Tuesday, 31 March 2015 11:02:08 UTC+1, Lars Brinkhoff wrote: >> Mark Wills <> writes: >> > Not sure what the flaws are. Here's my version of it: >> > >> > --BLOCK-00046--------- >> > : SYNONYM >> > CREATE BL WORD FIND DUP IF >> > SWAP , IMMEDIATE 1+ IF >> > DOES> @ EXECUTE >> > ELSE >> > DOES> STATE @ IF >> > @ , >> > ELSE >> > @ EXECUTE >> > THEN >> > THEN >> > ELSE >> > TRUE ABORT" Word not found" >> > THEN ; >> >> Here are some more tests you can try: > > Thanks for that Lars. I tested it against your code. > All passed ;-) > I'm perplexed by SYNONYM as defined above, since it has DOES> inside control structures. How on earth does that work?
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2015-03-31 16:52 +0000 |
| Message-ID | <551ad0c6$0$2986$e4fe514c@dreader35.news.xs4all.nl> |
| In reply to | #37773 |
In article <0165a96b-3372-4a43-8e77-045994fb5934@googlegroups.com>, Mark Wills <markwills1970@gmail.com> wrote: >On Tuesday, 31 March 2015 03:54:02 UTC+1, hughag...@gmail.com wrote: >> On Monday, March 30, 2015 at 7:27:22 PM UTC-7, HAA wrote: >> > Anton Ertl wrote: >> > > ... >> > > we standardized SYNONYM rather >> > > than ALIAS for this reason. >> > >> > SYNONYM has known flaws. It was chosen because it was supported. >> >> What are the known flaws of SYNONYM ? Also, what is the definition of >SYNONYM ? > >Not sure what the flaws are. Here's my version of it: > > >--BLOCK-00046--------- >: SYNONYM > CREATE BL WORD FIND DUP IF > SWAP , IMMEDIATE 1+ IF > DOES> @ EXECUTE > ELSE > DOES> STATE @ IF > @ , > ELSE > @ EXECUTE > THEN > THEN > ELSE > TRUE ABORT" Word not found" > THEN ; Oh boy. I don't think it is worthwhile to define SYNONYM pseudo portably. My comrade-in-arms Coos Haak tried this one and it didn't work on his Forth of r the test that has been snipped. (The SYNONYM he implemented himself passed.) So leave it to the implementor, e.g. my ALIAS ( xt "name" -- ) is : ALIAS NAME (CREATE) \ Create a header with name ( xt ) LATEST 3 CELLS MOVE ; This copies all the flags in cell 3, inclusive any the use may have defined. Such a simple definition using carnal knowledge and not trying to cater for all difference there might be between implementations, is much more reliable. > >.( SYNONYM loaded.) .( Usage: SYNONYM NewWord OldWord) > >Long time since I wrote this code. I just checked it handles >immediate words okay and it seems fine: > >: FOO ." FOO! " ; IMMEDIATE >SYNONYM BAR FOO >: TEST 1 2 BAR 3 ; >FOO! >TEST .S >1 2 3 <--TOP OK:3 And the known flaw is that it parses from the input stream other than to get the name for a to-be-defined word. E.g. INCLUDED is basal. INCLUDE is a mere convenience. 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 | "Alex McDonald" <blog@rivadpm.com> |
|---|---|
| Date | 2015-03-31 18:33 +0100 |
| Message-ID | <mfelnm$56k$1@dont-email.me> |
| In reply to | #37783 |
on 31/03/2015 17:52:22, Albert wrote:
> In article <0165a96b-3372-4a43-8e77-045994fb5934@googlegroups.com>,
> Mark Wills <markwills1970@gmail.com> wrote:
>>
>>
>>--BLOCK-00046---------
>>: SYNONYM
>> CREATE BL WORD FIND DUP IF
>> SWAP , IMMEDIATE 1+ IF
>> DOES> @ EXECUTE
>> ELSE
>> DOES> STATE @ IF
>> @ ,
>> ELSE
>> @ EXECUTE
>> THEN
>> THEN
>> ELSE
>> TRUE ABORT" Word not found"
>> THEN ;
>
> Oh boy.
> I don't think it is worthwhile to define SYNONYM
> pseudo portably. My comrade-in-arms Coos Haak
> tried this one and it didn't work on his Forth
> of r the test that has been snipped.
> (The SYNONYM he implemented himself passed.)
: synonym
: bl word find
>r compile, postpone ;
r> 1+ if immediate then ;
I think that should be pretty portable across ANS Forths. (I know, it
uses the deprectated FIND.)
[toc] | [prev] | [next] | [standalone]
| From | JennyB <jennybrien@googlemail.com> |
|---|---|
| Date | 2015-03-31 15:25 -0700 |
| Message-ID | <866e5680-c68d-40e6-9c92-8c7768ab8faa@googlegroups.com> |
| In reply to | #37784 |
Remember that SYNONYM can create a synonym with the identical name (but in a different wordlist) so in the OP's case you would do something like
ALSO standard
SYNONYM ALIAS ALIAS
...
PREVIOUS
The portable version that makes a new colon definition works, but to use CREATE you would need some input stream gymnastics to avoid having the new word find itself.
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2015-04-01 00:59 +0000 |
| Message-ID | <551b42d4$0$3016$e4fe514c@dreader35.news.xs4all.nl> |
| In reply to | #37788 |
In article <866e5680-c68d-40e6-9c92-8c7768ab8faa@googlegroups.com>,
JennyB <jennybrien@googlemail.com> wrote:
>Remember that SYNONYM can create a synonym with the identical name (but
>in a different wordlist) so in the OP's case you would do something like
>
> ALSO standard
> SYNONYM ALIAS ALIAS
> ...
> PREVIOUS
If I'm the OP you're talking about, let met try to pull this back on track.
Define syntactic sugar ^H^H^H^H^ a macro like abbreviation for the above
lines to make it convenient and usable,
like so
standard IMPORT ALIAS
>
>The portable version that makes a new colon definition works, but to use
>CREATE you would need some input stream gymnastics to avoid having the
>new word find itself.
--
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]
Page 1 of 4 [1] 2 3 4 Next page →
Back to top | Article view | comp.lang.forth
csiph-web