Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #42381 > unrolled thread
| Started by | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| First post | 2015-10-06 01:14 +0000 |
| Last post | 2015-10-08 07:29 +0000 |
| Articles | 7 on this page of 27 — 15 participants |
Back to article view | Back to comp.lang.forth
Re: Could Forth be getting a bit of traction? "WJ" <w_a_x_man@yahoo.com> - 2015-10-06 01:14 +0000
Re: Could Forth be getting a bit of traction? Jason Damisch <jasondamisch@yahoo.com> - 2015-10-06 10:47 -0700
Re: Could Forth be getting a bit of traction? Chris Curl <ccurl609@gmail.com> - 2015-10-06 11:01 -0700
Re: Could Forth be getting a bit of traction? Jason Damisch <jasondamisch@yahoo.com> - 2015-10-06 11:27 -0700
Re: Could Forth be getting a bit of traction? lehs <skydda.barnen@gmail.com> - 2015-10-06 12:08 -0700
Re: Could Forth be getting a bit of traction? Howerd <howerdo@yahoo.co.uk> - 2015-10-06 14:06 -0700
Re: Could Forth be getting a bit of traction? Jason Damisch <jasondamisch@yahoo.com> - 2015-10-06 16:15 -0700
Re: Could Forth be getting a bit of traction? Chris Curl <ccurl609@gmail.com> - 2015-10-06 21:48 -0700
Re: Could Forth be getting a bit of traction? stephen@mpeforth.com (Stephen Pelc) - 2015-10-07 12:19 +0000
Re: Could Forth be getting a bit of traction? Mark Wills <markwills1970@gmail.com> - 2015-10-07 07:40 -0700
Re: Could Forth be getting a bit of traction? Michael Barry <barrym95838@yahoo.com> - 2015-10-07 08:27 -0700
Re: Could Forth be getting a bit of traction? Coos Haak <chforth@hccnet.nl> - 2015-10-07 17:40 +0200
Re: Could Forth be getting a bit of traction? franck.bensusan@gmail.com - 2015-10-07 10:50 -0700
Re: Could Forth be getting a bit of traction? Coos Haak <chforth@hccnet.nl> - 2015-10-07 22:37 +0200
Re: Could Forth be getting a bit of traction? franck.bensusan@gmail.com - 2015-10-07 23:22 -0700
Re: Could Forth be getting a bit of traction? "Elizabeth D. Rather" <erather@forth.com> - 2015-10-07 09:14 -1000
Array Style (was Re: Could Forth be getting a bit of traction?) Howerd <howerdo@yahoo.co.uk> - 2015-10-07 13:23 -0700
Re: Could Forth be getting a bit of traction? Howerd <howerdo@yahoo.co.uk> - 2015-10-07 13:20 -0700
Re: Could Forth be getting a bit of traction? rickman <gnuarm@gmail.com> - 2015-10-07 12:13 -0400
Array Style ( was Re: Could Forth be getting a bit of traction? ) Howerd <howerdo@yahoo.co.uk> - 2015-10-07 13:36 -0700
Re: Array Style ( was Re: Could Forth be getting a bit of traction? ) rickman <gnuarm@gmail.com> - 2015-10-07 17:39 -0400
Array Style ( was Re: Could Forth be getting a bit of traction? ) Howerd <howerdo@yahoo.co.uk> - 2015-10-07 13:16 -0700
Re: Could Forth be getting a bit of traction? mhx@iae.nl - 2015-10-07 10:46 -0700
Array Style ( was Re: Could Forth be getting a bit of traction? ) Howerd <howerdo@yahoo.co.uk> - 2015-10-07 13:39 -0700
Re: Array Style ( was Re: Could Forth be getting a bit of traction? ) mhx@iae.nl - 2015-10-07 15:01 -0700
Re: Array Style ( was Re: Could Forth be getting a bit of traction? ) Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2015-10-09 22:05 +0200
Re: Could Forth be getting a bit of traction? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-10-08 07:29 +0000
Page 2 of 2 — ← Prev page 1 [2]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2015-10-07 17:39 -0400 |
| Subject | Re: Array Style ( was Re: Could Forth be getting a bit of traction? ) |
| Message-ID | <mv439t$3f2$1@dont-email.me> |
| In reply to | #42433 |
On 10/7/2015 4:36 PM, Howerd wrote:
> On Wednesday, October 7, 2015 at 5:13:38 PM UTC+1, rickman wrote:
>> On 10/7/2015 8:19 AM, Stephen Pelc wrote:
>>> On Tue, 6 Oct 2015 14:06:15 -0700 (PDT), Howerd <howe...@yahoo.co.uk>
>>> wrote:
>>>
>>>> Jason, Anton, Bernd, Marcel, Stephen et al : is it possible to use local va=
>>>> riables in a child definition? Does this depend on the implementation, and =
>>>> is it defined/allowed by ANS?
>>>
>>> There are no current mechanisms for Forth locals to be referenced in
>>> words other than the one in which they are defined.
>>>
>>> Some systems, e.g. VFX, do permit you to obtain an address of a local
>>> variable. That address can then be passed into another word. This
>>> feature is useful when interfacing to operating systems but is
>>> non-standard. Other systems, e.g. iForth, use the limitations to
>>> enhance the performance of locals.
>>
>> I believe there was a rather lengthy thread on this not too long ago.
>> People proposed a number of mechanisms to limit the use of the locals so
>> it would not cause problems when referencing them in other definitions
>> than the one they were defined in.
>>
>> --
>>
>> Rick
>
> Hi Rick,
>
> All of this is not convincing me that locals are a good thing.
> They are way to complicated for a simpleton like me ;-)
> Even though it is easy enough to take some syntactic sugar "{" and "}" and make it point to an allocated area on the return stack, there is an increase in complexity if you try to support them fully.
>
> It reminds me of why Forth uses RPN : you could easily add a few "BL WORD"s so that you define :
> : add ( n -- ) BL word count number + ; \ BL is $20
> then you can type :
> 1 + 1 . 2
> But if you do this you block the simple use of add , and have to start processing strings. Maybe you have re-invented Lisp?
I'm not sure what you are saying. I don't have a horse in this race. I
was merely pointing out that others are interested in the sharing of
locals and others have discussed this before.
I don't currently use locals but am open to learning about this if I
find the stack to be a problem at some point. I have written code that
seemed to have trouble with the stack because of a large number of
parameters which needed to be passed to a word. But I eventually worked
that out with different factoring. So for now, I'm good.
--
Rick
[toc] | [prev] | [next] | [standalone]
| From | Howerd <howerdo@yahoo.co.uk> |
|---|---|
| Date | 2015-10-07 13:16 -0700 |
| Subject | Array Style ( was Re: Could Forth be getting a bit of traction? ) |
| Message-ID | <473bbad4-7515-4df2-94f9-0f0aa4a6b71c@googlegroups.com> |
| In reply to | #42420 |
On Wednesday, October 7, 2015 at 1:19:39 PM UTC+1, Stephen Pelc wrote:
> On Tue, 6 Oct 2015 14:06:15 -0700 (PDT), Howerd <how...@yahoo.co.uk>
> wrote:
>
> >Jason, Anton, Bernd, Marcel, Stephen et al : is it possible to use local va=
> >riables in a child definition? Does this depend on the implementation, and =
> >is it defined/allowed by ANS?
>
> There are no current mechanisms for Forth locals to be referenced in
> words other than the one in which they are defined.
>
> Some systems, e.g. VFX, do permit you to obtain an address of a local
> variable. That address can then be passed into another word. This
> feature is useful when interfacing to operating systems but is
> non-standard. Other systems, e.g. iForth, use the limitations to
> enhance the performance of locals.
>
> 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
Hi Stephen,
Yes - I thought that this would be difficult, because the compiler would need to "postpone" the action of the local keywords "{" and "}", somehow...
Best regards,
Howerd
[toc] | [prev] | [next] | [standalone]
| From | mhx@iae.nl |
|---|---|
| Date | 2015-10-07 10:46 -0700 |
| Message-ID | <b11dba72-6a56-4be0-968e-6819a2507cff@googlegroups.com> |
| In reply to | #42404 |
On Tuesday, October 6, 2015 at 11:06:20 PM UTC+2, Howerd wrote: [..] > Jason, Anton, Bernd, Marcel, Stephen et al > : is it possible to use local variables in a child definition? > Does this depend on the implementation, and is it > defined/allowed by ANS? Does this answer 33% of your question? : det create , , ( a c -- ) does> ( b -- det ) @+ swap @ locals| a c b | b b * a c * 4 * - sqrt b - a 2* / ; FORTH> 1 1 det b FORTH> 2 b . -1 ok FORTH> -2 b . 1 ok -marcel
[toc] | [prev] | [next] | [standalone]
| From | Howerd <howerdo@yahoo.co.uk> |
|---|---|
| Date | 2015-10-07 13:39 -0700 |
| Subject | Array Style ( was Re: Could Forth be getting a bit of traction? ) |
| Message-ID | <9d5dd9e4-6bed-48b9-99ec-77758c5b0e38@googlegroups.com> |
| In reply to | #42426 |
On Wednesday, October 7, 2015 at 6:46:32 PM UTC+1, m...@iae.nl wrote: > On Tuesday, October 6, 2015 at 11:06:20 PM UTC+2, Howerd wrote: > [..] > > Jason, Anton, Bernd, Marcel, Stephen et al > > : is it possible to use local variables in a child definition? > > Does this depend on the implementation, and is it > > defined/allowed by ANS? > > Does this answer 33% of your question? > > : det create , , ( a c -- ) > does> ( b -- det ) > @+ swap @ locals| a c b | > b b * a c * 4 * - sqrt > b - a 2* / ; > FORTH> 1 1 det b > FORTH> 2 b . -1 ok > FORTH> -2 b . 1 ok > > -marcel Hi Marcel, I think it answers 100%, but only 33% in the positive. So it can be done, its not ANS and its behaviour in a standard system is ambiguous? Best regards, Howerd
[toc] | [prev] | [next] | [standalone]
| From | mhx@iae.nl |
|---|---|
| Date | 2015-10-07 15:01 -0700 |
| Subject | Re: Array Style ( was Re: Could Forth be getting a bit of traction? ) |
| Message-ID | <164063ad-3ca4-4397-994a-8d4e8270fe98@googlegroups.com> |
| In reply to | #42435 |
On Wednesday, October 7, 2015 at 10:39:24 PM UTC+2, Howerd wrote:
> On Wednesday, October 7, 2015 at 6:46:32 PM UTC+1, m...@iae.nl wrote:
> > On Tuesday, October 6, 2015 at 11:06:20 PM UTC+2, Howerd wrote:
> > [..]
> > > Jason, Anton, Bernd, Marcel, Stephen et al
> > > : is it possible to use local variables in a child definition?
> > > Does this depend on the implementation, and is it
> > > defined/allowed by ANS?
> >
> > Does this answer 33% of your question?
> >
> > : det create , , ( a c -- )
> > does> ( b -- det )
> > @+ swap @ locals| a c b |
> > b b * a c * 4 * - sqrt
> > b - a 2* / ;
> > FORTH> 1 1 det b
> > FORTH> 2 b . -1 ok
> > FORTH> -2 b . 1 ok
> >
> > -marcel
>
> Hi Marcel,
>
> I think it answers 100%, but only 33% in the positive.
> So it can be done, its not ANS and its behaviour in a
> standard system is ambiguous?
Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit
: sqrt s>f fsqrt f>s ; ok
: det create , , ( a c -- ) compiled
does> ( b -- det ) compiled
dup @ swap cell+ @ locals| a c b | compiled
b b * a c * 4 * - sqrt compiled
b - a 2* / ; ok
1 1 det b ok
2 b . -1 ok
-2 b . 1 ok
Looks pretty standard to me :-)
-marcel
[toc] | [prev] | [next] | [standalone]
| From | Roelf Toxopeus <rt4all@notthis.hetnet.nl> |
|---|---|
| Date | 2015-10-09 22:05 +0200 |
| Subject | Re: Array Style ( was Re: Could Forth be getting a bit of traction? ) |
| Message-ID | <56181e00$0$9583$e4fe514c@textnews.kpn.nl> |
| In reply to | #42438 |
On 08/10/15 00:01, mhx@iae.nl wrote:
> On Wednesday, October 7, 2015 at 10:39:24 PM UTC+2, Howerd wrote:
>> On Wednesday, October 7, 2015 at 6:46:32 PM UTC+1, m...@iae.nl wrote:
>>> On Tuesday, October 6, 2015 at 11:06:20 PM UTC+2, Howerd wrote:
>>> [..]
>>>> Jason, Anton, Bernd, Marcel, Stephen et al
>>>> : is it possible to use local variables in a child definition?
>>>> Does this depend on the implementation, and is it
>>>> defined/allowed by ANS?
>>>
>>> Does this answer 33% of your question?
>>>
>>> : det create , , ( a c -- )
>>> does> ( b -- det )
>>> @+ swap @ locals| a c b |
>>> b b * a c * 4 * - sqrt
>>> b - a 2* / ;
>>> FORTH> 1 1 det b
>>> FORTH> 2 b . -1 ok
>>> FORTH> -2 b . 1 ok
>>>
>>> -marcel
>>
>> Hi Marcel,
>>
>> I think it answers 100%, but only 33% in the positive.
>> So it can be done, its not ANS and its behaviour in a
>> standard system is ambiguous?
>
> Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
> Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
> Type `bye' to exit
> : sqrt s>f fsqrt f>s ; ok
> : det create , , ( a c -- ) compiled
> does> ( b -- det ) compiled
> dup @ swap cell+ @ locals| a c b | compiled
> b b * a c * 4 * - sqrt compiled
> b - a 2* / ; ok
> 1 1 det b ok
> 2 b . -1 ok
> -2 b . 1 ok
>
>
> Looks pretty standard to me :-)
SwiftForth i386-Mac OS X 3.5.8 24 Sep-2015
: sqrt s>f fsqrt f>s ; ok
: det create , , ( a c -- )
does> ( b -- det )
dup @ swap cell+ @ locals| a c b |
b b * a c * 4 * - sqrt
b - a 2* / ; ok
1 1 det b ok
2 b . -1 ok
-2 b . 1 ok
VFX Forth for OS X IA32
© MicroProcessor Engineering Ltd, 1998-2014
Version: 4.71 [build 0255]
Build date: 23 October 2014
Free dictionary = 7767740 bytes [7585kb]
: sqrt s>f fsqrt f>s ; ok
: det create , , ( a c -- )
does> ( b -- det )
dup @ swap cell+ @ locals| a c b |
b b * a c * 4 * - sqrt
b - a 2* / ; ok
1 1 det b ok
2 b . -1 ok
-2 b . 1 ok
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-10-08 07:29 +0000 |
| Message-ID | <2015Oct8.092943@mips.complang.tuwien.ac.at> |
| In reply to | #42404 |
Howerd <howerdo@yahoo.co.uk> writes:
>Jason, Anton, Bernd, Marcel, Stephen et al : is it possible to use local va=
>riables in a child definition? Does this depend on the implementation, and =
>is it defined/allowed by ANS?
Forth-2012 (and -94) says:
|13.3.3.1 Compilation semantics
|
|d) Separate sets of locals may be declared in defining words before
|DOES> for use by the defining word, and after DOES> for use by the
|word defined.
I.e., the following is standard:
: foo
create {: A :} \ A visible here
does>
{: B :} \ B (and only B) visible here
;
Whether systems other than Gforth implement this correctly I have not
tested.
- 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 2015: http://www.rigwit.co.uk/EuroForth2015/
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.forth
csiph-web