Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #16705 > unrolled thread
| Started by | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| First post | 2012-10-25 20:49 +0200 |
| Last post | 2012-10-26 13:38 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.forth
Headless child words mhx@iae.nl (Marcel Hendrix) - 2012-10-25 20:49 +0200
Headless child words JennyB <jennybrien@googlemail.com> - 2012-10-25 21:49 -0700
Re: Headless child words Arnold Doray <invalid@invalid.com> - 2012-10-26 13:38 +0000
| From | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| Date | 2012-10-25 20:49 +0200 |
| Subject | Headless child words |
| Message-ID | <86861510938435@frunobulax.edu> |
Is there a standard way to create a headerless word that uses the DOES> part of its parent? Sort of like: : foo create-noname , does> @ ; Foo produces an xt when given data: 44 foo ( -- xt ) -marcel
[toc] | [next] | [standalone]
| From | JennyB <jennybrien@googlemail.com> |
|---|---|
| Date | 2012-10-25 21:49 -0700 |
| Message-ID | <e921ecd0-e62f-4a16-85ca-93457d3ab9ca@googlegroups.com> |
| In reply to | #16705 |
Not using DOES> but...
: BIND ( data xt ) 2, HERE 2 CELLS - ;
data xt BIND ... 2@ EXECUTE
Or if BIND must produce an xt...
: BIND ( data xt ) 2>R :NONAME
R> POSTPONE LITERAL
R> POSTPONE LITERAL POSTPONE EXECUTE POSTPONE ;
;
Totally untested (it's a long time since I've written any Forth )
[toc] | [prev] | [next] | [standalone]
| From | Arnold Doray <invalid@invalid.com> |
|---|---|
| Date | 2012-10-26 13:38 +0000 |
| Message-ID | <k6e3oh$lao$1@dont-email.me> |
| In reply to | #16705 |
On Thu, 25 Oct 2012 20:49:49 +0200, Marcel Hendrix wrote:
You'd probably want to use quotations. In Mini it's:
: foo { x } [: x ;] ;
ok
44 foo
ok
.S
<1> com.terraweather.mini.XT@25cd0888 ok
execute .S
.S
<1> 44 ok
I don't think there is a cleaner way to do it in ANS.
Here's an ugly hack:
: create-name ( -- xt )
s" create :anon ' :anon" evaluate ;
: foo create-name >R , R> does> @ ;
44 foo execute .S
44 ok
Cheers
Arnold
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.forth
csiph-web