Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #33730 > unrolled thread
| Started by | JennyB <jennybrien@googlemail.com> |
|---|---|
| First post | 2014-10-07 07:33 -0700 |
| Last post | 2014-10-07 20:23 +0100 |
| Articles | 9 on this page of 29 — 10 participants |
Back to article view | Back to comp.lang.forth
Can every Forth do this? JennyB <jennybrien@googlemail.com> - 2014-10-07 07:33 -0700
Re: Can every Forth do this? Roger Levy <roger.levy@gmail.com> - 2014-10-07 08:58 -0700
Re: Can every Forth do this? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-10-07 16:16 +0000
Re: Can every Forth do this? november.nihal@gmail.com - 2014-10-08 06:17 -0700
Re: Can every Forth do this? Mark Wills <markwills1970@gmail.com> - 2014-10-08 09:55 -0700
Re: Can every Forth do this? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-10-09 15:26 +0000
Re: Can every Forth do this? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2014-10-09 19:42 +0100
Re: Can every Forth do this? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-10-07 18:16 +0000
Re: Can every Forth do this? Jason Damisch <jasondamisch@yahoo.com> - 2014-10-07 11:32 -0700
Re: Can every Forth do this? Mark Wills <markwills1970@gmail.com> - 2014-10-07 14:27 -0700
Re: Can every Forth do this? "Elizabeth D. Rather" <erather@forth.com> - 2014-10-07 13:38 -1000
Re: Can every Forth do this? Mark Wills <markwills1970@gmail.com> - 2014-10-07 20:21 -0700
Re: Can every Forth do this? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-10-08 11:33 +0000
Re: Can every Forth do this? JennyB <jennybrien@googlemail.com> - 2014-10-08 06:25 -0700
Re: Can every Forth do this? november.nihal@gmail.com - 2014-10-08 08:14 -0700
Re: Can every Forth do this? Mark Wills <markwills1970@gmail.com> - 2014-10-08 10:10 -0700
Re: Can every Forth do this? JennyB <jennybrien@googlemail.com> - 2014-10-08 11:42 -0700
Re: Can every Forth do this? Roger Levy <roger.levy@gmail.com> - 2014-10-08 12:31 -0700
Re: Can every Forth do this? JennyB <jennybrien@googlemail.com> - 2014-10-09 07:03 -0700
Re: Can every Forth do this? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-10-08 19:33 +0000
Re: Can every Forth do this? november.nihal@gmail.com - 2014-10-08 16:39 -0700
Re: Can every Forth do this? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-10-08 23:45 +0000
Re: Can every Forth do this? Harold <hzrabbie@gmail.com> - 2014-10-08 14:23 -0700
Re: Can every Forth do this? "Elizabeth D. Rather" <erather@forth.com> - 2014-10-08 12:48 -1000
Re: Can every Forth do this? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-10-08 23:39 +0000
Re: Can every Forth do this? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-10-08 13:17 +0000
Re: Can every Forth do this? Roger Levy <roger.levy@gmail.com> - 2014-10-08 07:33 -0700
Re: Can every Forth do this? Roger Levy <roger.levy@gmail.com> - 2014-10-08 07:33 -0700
Re: Can every Forth do this? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2014-10-07 20:23 +0100
Page 2 of 2 — ← Prev page 1 [2]
| From | november.nihal@gmail.com |
|---|---|
| Date | 2014-10-08 16:39 -0700 |
| Message-ID | <1e65cae9-b617-4a83-9938-a606d55dc904@googlegroups.com> |
| In reply to | #33767 |
\\\ When I use counted strings, I prefer :- count ==> ( str -- addr len ) where len is a byte range 0 .. 256 lcount ==> ( str -- addr len ) where len is a cell range 0 .. 2^32-1 Also have wcount ==> ( str -- addr len ) where len is a cell range 0 .. 2^16-1 But I tend to use lcount more often.
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2014-10-08 23:45 +0000 |
| Message-ID | <5435cc87$0$15817$e4fe514c@dreader35.news.xs4all.nl> |
| In reply to | #33776 |
In article <1e65cae9-b617-4a83-9938-a606d55dc904@googlegroups.com>,
<november.nihal@gmail.com> wrote:
>\\\
>
>When I use counted strings, I prefer :-
>
> count ==> ( str -- addr len ) where len is a byte range 0 .. 256
>lcount ==> ( str -- addr len ) where len is a cell range 0 .. 2^32-1
>
>Also have
>
>wcount ==> ( str -- addr len ) where len is a cell range 0 .. 2^16-1
>
>But I tend to use lcount more often.
It is a bad idea to have 8 16 32 or 64 bits for the string length.
It should be a cell and the word must be named $@ ("string-fetch").
I grant COUNT a place, but I've renamed it to $@-BD.
(That is BD for brain-damaged.)
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 | Harold <hzrabbie@gmail.com> |
|---|---|
| Date | 2014-10-08 14:23 -0700 |
| Message-ID | <31ffdcd7-7d37-4c10-8d00-aab2447dd3d9@googlegroups.com> |
| In reply to | #33750 |
On Wednesday, October 8, 2014 4:33:25 AM UTC-7, Albert van der Horst wrote: > In article <YPudnUS6_47k5KnJnZ2dnUU7-cOdnZ2d@supernews.com>, > Indeed in ciforth you would have > > 9 CONSTANT nine > ' nine >DFA @ . > 9 OK > > But that is because CONSTANT is defined in the standard and can be > implemented evert which way. > > If constant is defined in the above way, you can get from nine to 9 > by the phrase > > ' nine >BODY @ > > which is AFAIK perfectly sound ISO Forth. > No it's not according to Forth 94. 6.1.0550 >BODY ( xt -- a-addr ) An ambiguous condition exists if xt is not for a word defined via CREATE. Since "nine" is defined via CONSTANT, it may or may not work
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2014-10-08 12:48 -1000 |
| Message-ID | <FsCdnUfLLc2zIqjJnZ2dnUU7-emdnZ2d@supernews.com> |
| In reply to | #33772 |
On 10/8/14 11:23 AM, Harold wrote: > On Wednesday, October 8, 2014 4:33:25 AM UTC-7, Albert van der Horst wrote: >> In article <YPudnUS6_47k5KnJnZ2dnUU7-cOdnZ2d@supernews.com>, > >> Indeed in ciforth you would have >> >> 9 CONSTANT nine >> ' nine >DFA @ . >> 9 OK >> >> But that is because CONSTANT is defined in the standard and can be >> implemented evert which way. >> >> If constant is defined in the above way, you can get from nine to 9 >> by the phrase >> >> ' nine >BODY @ >> >> which is AFAIK perfectly sound ISO Forth. >> > > No it's not according to Forth 94. > > 6.1.0550 >BODY > ( xt -- a-addr ) > An ambiguous condition exists if xt is not for a word defined via CREATE. > > Since "nine" is defined via CONSTANT, it may or may not work > Well, per subsequent clarifications by the OP, being restricted to CREATE is not a problem. He just happened to pick CONSTANT as an example. Cheers, Elizabeth -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2014-10-08 23:39 +0000 |
| Message-ID | <5435cb1e$0$15817$e4fe514c@dreader35.news.xs4all.nl> |
| In reply to | #33772 |
In article <31ffdcd7-7d37-4c10-8d00-aab2447dd3d9@googlegroups.com>, Harold <hzrabbie@gmail.com> wrote: >On Wednesday, October 8, 2014 4:33:25 AM UTC-7, Albert van der Horst wrote: >> In article <YPudnUS6_47k5KnJnZ2dnUU7-cOdnZ2d@supernews.com>, > >> Indeed in ciforth you would have >> >> 9 CONSTANT nine >> ' nine >DFA @ . >> 9 OK >> >> But that is because CONSTANT is defined in the standard and can be >> implemented evert which way. >> >> If constant is defined in the above way, you can get from nine to 9 >> by the phrase >> >> ' nine >BODY @ >> >> which is AFAIK perfectly sound ISO Forth. >> > >No it's not according to Forth 94. > >6.1.0550 >BODY > ( xt -- a-addr ) >An ambiguous condition exists if xt is not for a word defined via CREATE. > >Since "nine" is defined via CONSTANT, it may or may not work Look at the original post. The question was about : CONSTANT CREATE , DOES> @ ; not about just any constant given in a Forth. So nine is defined via CREATE and there is no ambiguous condition. 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 | 2014-10-08 13:17 +0000 |
| Message-ID | <2014Oct8.151705@mips.complang.tuwien.ac.at> |
| In reply to | #33742 |
"Elizabeth D. Rather" <erather@forth.com> writes:
>On 10/7/14 11:27 AM, Mark Wills wrote:
>> The parent is the word that creates the child.
>>
>> : constant create , does> @ ;
>> 9 constant nine
>>
>> Constant is the parent of nine.
>>
>
>So, if the question is whether you can *always* get to CONSTANT from
>nine, the answer is no.
No, that was not the question. The two questions are about an
identifier for a does>, called n in the original posting; in an
implementation this could be the address of the code after the DOES>.
The first question is whether you could get at this identifier from
the child of a CREATE...DOES> word. The second question was whether
you could get at it from the CREATE...DOES> word itself.
>In some implementations you could get to nine's
>parent from its xt, but some implementations of CONSTANT compile
>literals in place or do other things, so there is no xt.
This is not about some implementations of CONSTANT, this is about
CREATE...DOES> words, with one example being
: constant create , does> @ ;
You cannot get at this CONSTANT from NINE, but you can get at the
address of the code after the DOES>, because otherwise EXECUTE would
not work.
- 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 | Roger Levy <roger.levy@gmail.com> |
|---|---|
| Date | 2014-10-08 07:33 -0700 |
| Message-ID | <03038e55-6c9a-4c1d-b9ce-42068b0f4b3f@googlegroups.com> |
| In reply to | #33742 |
Exactly, and what's more I think extending CREATE DOES> is inappropriate. It shouldn't be confused with some kind of idea of a primitive form of OOP waiting to be enhanced, even though it's been called a form of object orientation (wince). Don't extend it if you want to be compatible...
[toc] | [prev] | [next] | [standalone]
| From | Roger Levy <roger.levy@gmail.com> |
|---|---|
| Date | 2014-10-08 07:33 -0700 |
| Message-ID | <482b09f2-ad0b-462e-83e5-bf556d18f2f0@googlegroups.com> |
| In reply to | #33759 |
I take it back - do extend it if you re-implement in standard Forth so you can define the assumptions.
[toc] | [prev] | [next] | [standalone]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2014-10-07 20:23 +0100 |
| Message-ID | <m11ek7$pqq$1@dont-email.me> |
| In reply to | #33730 |
On 07/10/2014 15:33, JennyB wrote: > I've often seen implementation-specific versions of this, or its equivalent, and wondered if there are any Forth where it is not practical: > > DOES xt -- n > Where xt belongs to a word defined by > CREATE ... DOES> > n uniquely identifies its parent. > > Is it also practical to derive n directly from the parent without creating a prototype child and then calling DOES ? > .. > I agree with Albert - I don't know what you're asking. -- Gerry
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.forth
csiph-web