Re: RfD - Enhanced local variable syntax (long)
  Home FAQ Contact Sign in
comp.lang.forth only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.forth Profile…
 Up
Re: RfD - Enhanced local variable syntax (long)         


Author: Stephen Pelc
Date: Aug 22, 2006 02:42

On 21 Aug 2006 16:04:53 -0700, "Alex McDonald"
btopenworld.com> wrote:
>> Agree with the above, and would add
>>
>> 5) Current implementations of { are diverging in the facilities they
>> provide.

It's the function of a standard to encourage people to use the
same names for the same function, but it is not the purpose to
stop new facilities being added to implementations.
>> 6) { and } are visually confusing. Perhaps select another character or
>> string, which would allow existing implementations to do their own
>> thing unmolested.

Common practice is to use { ... }. Is changing a name in common use
because we need new glasses or bigger monitors good enough reason
for change?
Show full article (2.26Kb)
14 Comments
Re: Noob: Creating (create)         


Author: Elizabeth D Rather
Date: Aug 2, 2006 13:56

Mark Carter wrote:
> I'm playing with win32forth, trying to figure out how I could make the
> word (create) which would work inside a colon definition. So I could do:
> : makeit (create) foo 1 cell allot ;
>
> I'm figuring that (create) must be an immediate word - the problem is
> how to look ahead to get the foo. What's the answer?

How about:

: (create) CREATE ; IMMEDIATE

When CREATE is executed during compilation of makeit, it'll do the
look-ahead and construct foo.

But I find that pretty limiting, because makeit always makes the same
name, not things that are then individually useful. How were you
planning to use this?

By the way, in FORTH, Inc. products we have a word called (create) which
does the work of constructing the dictionary entry. It's used by most
defining words.

Cheers,
Elizabeth
Show full article (1.21Kb)
3 Comments
Re: Noob: Creating (create)         


Author: Mark Carter
Date: Aug 2, 2006 14:43

Elizabeth D Rather wrote:
> Mark Carter wrote:
>> I'm playing with win32forth, trying to figure out how I could make the
>> word (create) which would work inside a colon definition. So I could do:
>> : makeit (create) foo 1 cell allot ;
>>
>> I'm figuring that (create) must be an immediate word - the problem is
>> how to look ahead to get the foo. What's the answer?
>
> How about:
>
> : (create) CREATE ; IMMEDIATE
>
> When CREATE is executed during compilation of makeit, it'll do the
> look-ahead and construct foo.

I actually came up with that - but there's a snag - it's created when
the compiler compiles, rather than at run-time.
Show full article (2.75Kb)
2 Comments
Re: Noob: Creating (create)         


Author: Elizabeth D Rather
Date: Aug 2, 2006 18:49

Mark Carter wrote:
> Elizabeth D Rather wrote:
>> Mark Carter wrote:
>>> I'm playing with win32forth, trying to figure out how I could make
>>> the word (create) which would work inside a colon definition. So I
>>> could do:
>>> : makeit (create) foo 1 cell allot ;
>>>
>>> I'm figuring that (create) must be an immediate word - the problem is
>>> how to look ahead to get the foo. What's the answer?
>>
>> How about:
>>
>> : (create) CREATE ; IMMEDIATE
>>
>> When CREATE is executed during compilation of makeit, it'll do the
>> look-ahead and construct foo.
>
> I actually came up with that - but there's a snag - it's created when
> the compiler compiles, rather than at run-time. ...
Show full article (4.43Kb)
1 Comment
Re: Noob: Creating (create)         


Author: Mark Carter
Date: Aug 3, 2006 04:17

Elizabeth D Rather wrote:
> : well-group ( n -- ) 0 ?do wells: loop ;
> 3 well-group t-d101 tp t-d103

Good idea. I'll use that. I'll probably try to implement things in a way
like (without worrying about specifics):
3 well-group: testcond d101 tp d103
so that they can be read with something as simple as the statement
testcond read-group
> Not all that clever ;-)

I've had a quick read on chapter 11 of the Forth books - the one that
has LEAVE, POSTPONE, [ , etc. in it. It'll probably take me a few more
iterations before I'm more convinced I know what I'm doing.

It'd be nice to see how some Forth words (BEGIN, WHILE, UNTIL, IF, etc.)
could be implemented in Forth,
> Cheers,
> Elizabeth

Many thanks for your response.
Show full article (1.78Kb)
no comments
Re: Noob: Creating (create)         


Author: Stephen Pelc
Date: Aug 3, 2006 05:25

On Wed, 02 Aug 2006 21:42:38 +0100, Mark Carter privacy.net>
wrote:
>I'm playing with win32forth, trying to figure out how I could make the
>word (create) which would work inside a colon definition. So I could do:
>: makeit (create) foo 1 cell allot ;
>
>I'm figuring that (create) must be an immediate word - the problem is
>how to look ahead to get the foo. What's the answer?

The factor we use is called $CREATE ( addr len -- ). It avoids the
look-ahead problem and can be used inside CREATE itself. Most Forths
have an equivalent, but the name of the word has not been
standardised. Using it, your word would look like:

: makeit \ --
\ Creates a one cell variable called FOO.
s" foo" $create 1 cell allot ;

You will find that your code is *much* easier to maintain and
read if you *always* put in a stack comment and a short description
of the word.

Stephen
Show full article (1.13Kb)
1 Comment
Re: Noob: Creating (create)         


Author: Mark Carter
Date: Aug 3, 2006 06:31

Stephen Pelc wrote:
> On Wed, 02 Aug 2006 21:42:38 +0100, Mark Carter privacy.net>
> wrote:
> The factor we use is called $CREATE ( addr len -- ).

win32forth doesn't appear to have it - I've searched the whole of its
dictionary.
no comments
Re: Noob: Creating (create)         


Author: J Thomas
Date: Aug 3, 2006 06:59

Mark Carter wrote:
> Stephen Pelc wrote:
>> On Wed, 02 Aug 2006 21:42:38 +0100, Mark Carter privacy.net>
>> wrote:
>> The factor we use is called $CREATE ( addr len -- ).
> win32forth doesn't appear to have it - I've searched the whole of its
> dictionary.

You might try

look CREATE
or
see CREATE

Maybe you'll get a decompiled version, or a look at the source code.

You might be able to see a word that does the same thing. Or maybe it
won't be quite the same thing.

There are various trade-offs to using the deep details of your
compiler. You might get simpler code. You get locked into your
particular Forth compiler. It gets harder for anybody else to maintain
your code.
Show full article (1.73Kb)
1 Comment
Re: Noob: Creating (create)         


Author: Mark Carter
Date: Aug 3, 2006 09:25

J Thomas wrote:
> Mark Carter wrote:
>> Stephen Pelc wrote:
>>> On Wed, 02 Aug 2006 21:42:38 +0100, Mark Carter privacy.net>
>>> wrote:
>
>>> The factor we use is called $CREATE ( addr len -- ).
>
>> win32forth doesn't appear to have it - I've searched the whole of its
>> dictionary.
>
> You might try
>
> look CREATE
> or
> see CREATE
Show full article (0.83Kb)
no comments
Re: Noob: Creating (create)         


Author: George Hubert
Date: Aug 3, 2006 09:37

J Thomas wrote:
> Mark Carter wrote:
>> Stephen Pelc wrote:
>>> On Wed, 02 Aug 2006 21:42:38 +0100, Mark Carter privacy.net>
>>> wrote:
>
>>> The factor we use is called $CREATE ( addr len -- ).
>
>> win32forth doesn't appear to have it - I've searched the whole of its
>> dictionary.
>
> You might try
>
> look CREATE
> or
> see CREATE
>

In Win32Forth you have;
Show full article (3.81Kb)
1 Comment
1 2