Google Groups Home
Help | Sign in
RfD - Enhanced local variable syntax (long)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 50 of 72 - Collapse all < Older  Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Andreas Kochenburger  
View profile
 More options Aug 22 2006, 2:48 am
Newsgroups: comp.lang.forth, comp.lang.forth.mac
From: Andreas Kochenburger <a...@nospam.com>
Date: Tue, 22 Aug 2006 08:48:21 +0200
Local: Tues, Aug 22 2006 2:48 am
Subject: Re: RfD - Enhanced local variable syntax (long)
On Mon, 21 Aug 2006 11:14:20 GMT, stephen...@mpeforth.com (Stephen

Pelc) wrote:
>Everything after '--' is discarded and ignored. It's defined
>so that formal comments can be used. I'll update the text.

Then everything after -- is comment. IMHO one should not mix
unnecessarily compiler instructions and comments within the same
syntax. You could put any misleading things after --.
Andreas
-------
A computer is like an old Greek god, with a lot of rules and no mercy.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Pelc  
View profile
 More options Aug 22 2006, 5:07 am
Newsgroups: comp.lang.forth, comp.lang.forth.mac
From: stephen...@mpeforth.com (Stephen Pelc)
Date: Tue, 22 Aug 2006 09:07:26 GMT
Local: Tues, Aug 22 2006 5:07 am
Subject: Re: RfD - Enhanced local variable syntax (long)
On Tue, 22 Aug 2006 08:48:21 +0200, Andreas Kochenburger

<a...@nospam.com> wrote:
>Then everything after -- is comment. IMHO one should not mix
>unnecessarily compiler instructions and comments within the same
>syntax. You could put any misleading things after --.

It is very common practice to put a stack comment on the definition
line of a word.

: foo ( a b c | e f -- d }
\ *G FOO does something useful

Modern systems, e.g. DocGen and Brad Eckert's DexH extension,
can use this line to produce documentation. We do not
want such systems to have to provide two lines with the
same information

: foo \ a b c -- d
\ *G FOO does something useful
  ( a b c | e f -- d }

Having two definitions of the same thing is a recipe for error.
Enabling the tail after '--' saves keystrokes. Note that '--'
is not mandatory.

Stephen

--
Stephen Pelc, stephen...@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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Pelc  
View profile
 More options Aug 22 2006, 5:42 am
Newsgroups: comp.lang.forth, comp.lang.forth.mac
From: stephen...@mpeforth.com (Stephen Pelc)
Date: Tue, 22 Aug 2006 09:42:48 GMT
Local: Tues, Aug 22 2006 5:42 am
Subject: Re: RfD - Enhanced local variable syntax (long)
On 21 Aug 2006 16:04:53 -0700, "Alex McDonald"

<alex_...@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?

>7) LOCALS| has the following restrictions on the use of the rstack;

>13.3.3.2 Syntax restrictions
>c) Locals shall not be declared until values previously placed on the
>return stack within the definition have been removed;

Removing this restriction would break code. I will add it.

>d) After a definition's locals have been declared, a program may place
>data on the return stack. However, if this is done, locals shall not be
>accessed until those values have been removed from the return stack;

Do any current systems suffer if this restriction is removed?
Implementers please respond! Current MPE systems will not suffer
unless { ... } is used a second time - should this be an ambiguous
condition?

Similarly, many current systesms, including MPE's, will break
if { ... } is used inside a control structure, e.g.

: foo   \ ...
  ... if
    { a b c -- }
    ...
  else
    ...
  then
;

I propose to add this as an amiguous condition as below.

Ambiguous conditions:
a) The { ... } text extends over more than one line.
b) The expression for local buffer size does not return a single
   cell.
c) { ... } shall not be declared until values previously placed
   on the return stack within the definition have been removed.
d) { ... } is declared within a control structure.

Stephen

--
Stephen Pelc, stephen...@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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Pelc  
View profile
 More options Aug 22 2006, 5:47 am
Newsgroups: comp.lang.forth
From: stephen...@mpeforth.com (Stephen Pelc)
Date: Tue, 22 Aug 2006 09:47:43 GMT
Local: Tues, Aug 22 2006 5:47 am
Subject: Re: RfD - Enhanced local variable syntax (long)

On Tue, 22 Aug 2006 01:37:36 GMT, m...@iae.nl (Marcel Hendrix) wrote:
>FVALUE has always been in tForth and iForth. I meant that for a standard
>there must at least be two conflicting implementations.

Conflict argues against standardisation. Do a proposal for
FVALUE and another for +TO. You may be pleasantly surprised.

Stephen

--
Stephen Pelc, stephen...@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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Kochenburger  
View profile
 More options Aug 22 2006, 6:21 am
Newsgroups: comp.lang.forth, comp.lang.forth.mac
From: Andreas Kochenburger <a...@nospam.com>
Date: Tue, 22 Aug 2006 12:21:17 +0200
Local: Tues, Aug 22 2006 6:21 am
Subject: Re: RfD - Enhanced local variable syntax (long)
On 21 Aug 2006 16:04:53 -0700, "Alex McDonald"

<alex_...@btopenworld.com> wrote:
>c) Locals shall not be declared until values previously placed on the
>return stack within the definition have been removed;

I'd prefer that the locals definition must be the first definition
within a word, i.e. appear right after : NAME ..
This can easily be checked by the compiler.

>d) After a definition's locals have been declared, a program may place
>data on the return stack. However, if this is done, locals shall not be
>accessed until those values have been removed from the return stack;

This is an unnecessary and contraproductive restriction. I'd consider
such locals implementations seriously flawed.

Andreas
-------
1 + 1 = 3, for large values of 1.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ward mcfarland  
View profile
 More options Aug 22 2006, 8:05 am
Newsgroups: comp.lang.forth
From: w...@megawolf.com (ward mcfarland)
Date: Tue, 22 Aug 2006 08:05:18 -0400
Local: Tues, Aug 22 2006 8:05 am
Subject: Re: RfD - Enhanced local variable syntax (long)
Julian V. Noble <j...@virginia.edu> wrote:

> In the great tradition of weighing in where angels fear to,

>    Re: limit of 8 locals.

>    Is a word that needs more than 8 a properly factored word?

I agree that 8 is usually more than enough for passed in arguments.  But
if you also want to keep track of a few truly "local" data items as
well.

At least two FSL files use 9 or 10 locals in a couple of words, as I
recall - one of the few non-standard usages that I encountered in the
whole library.  Of course, many of the FSL words are not what I would
call "well-factored" ;-)

gaussj.seq
SVD.seq


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex McDonald  
View profile
 More options Aug 22 2006, 8:36 am
Newsgroups: comp.lang.forth, comp.lang.forth.mac
From: "Alex McDonald" <alex_...@btopenworld.com>
Date: 22 Aug 2006 05:36:37 -0700
Local: Tues, Aug 22 2006 8:36 am
Subject: Re: RfD - Enhanced local variable syntax (long)

Andreas Kochenburger wrote:
> On 21 Aug 2006 16:04:53 -0700, "Alex McDonald"
> <alex_...@btopenworld.com> wrote:
> >c) Locals shall not be declared until values previously placed on the
> >return stack within the definition have been removed;

> I'd prefer that the locals definition must be the first definition
> within a word, i.e. appear right after : NAME ..
> This can easily be checked by the compiler.

It can't be parsed for as it would break a lot of code. It can be
detected only if { can ascertain that there's been no code generated
between : and { . Would that not give optimising compilers some
difficulties?

--
Regards
Alex McDonald


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
J Thomas  
View profile
 More options Aug 22 2006, 9:00 am
Newsgroups: comp.lang.forth
From: "J Thomas" <jethom...@gmail.com>
Date: 22 Aug 2006 06:00:05 -0700
Local: Tues, Aug 22 2006 9:00 am
Subject: Re: RfD - Enhanced local variable syntax (long)

Stephen Pelc wrote:
> On Tue, 22 Aug 2006 01:37:36 GMT, m...@iae.nl (Marcel Hendrix) wrote:
> >FVALUE has always been in tForth and iForth. I meant that for a standard
> >there must at least be two conflicting implementations.
> Conflict argues against standardisation. Do a proposal for
> FVALUE and another for +TO. You may be pleasantly surprised.

I may be wrong, but I had the idea that he was making the cynical
observation that until there are two conflicting implementations no one
will put in the effort to try to make one of them standard.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
J Thomas  
View profile
 More options Aug 22 2006, 9:26 am
Newsgroups: comp.lang.forth, comp.lang.forth.mac
From: "J Thomas" <jethom...@gmail.com>
Date: 22 Aug 2006 06:26:48 -0700
Local: Tues, Aug 22 2006 9:26 am
Subject: Re: RfD - Enhanced local variable syntax (long)

Alex McDonald wrote:
> Andreas Kochenburger wrote:
> > I'd prefer that the locals definition must be the first definition
> > within a word, i.e. appear right after : NAME ..
> > This can easily be checked by the compiler.
> It can't be parsed for as it would break a lot of code. It can be
> detected only if { can ascertain that there's been no code generated
> between : and { . Would that not give optimising compilers some
> difficulties?

If you want to check for that, you could have { be something that :
:NONAME and DOES> check. Any other time it doesn't work or gives an
error message.

It wouldn't break code for the standard to say not to define locals
elsewhere -- code which does that would be just as portable as it is
now. Any implementator who wants to let people define locals elsewhere
could do so. The question is whether it would  be good to require
implementors to allow locals definition elsewhere. And if so, which
places should locals definition be allowed?

Good optimising compilers will put locals in available registers and
will only move them out of the registers when the registers must be
used for something else -- for example a called word that uses locals,
or a word in another task that uses locals.

But less-optimised Forths will tend to put locals on the return stack,
and if they do there's a question what other return-stack uses might
interfere with locals or vice versa. What I remember for that is direct
use of the return stack ( >R etc), loops, and calls. Calls are no
problem, you won't use your locals inside a word you call and the
return stack will be clean when that word returns.

Implementations that call a deeper routine when they switch to compile
state are already nonstandard so that shouldn't be a problem.

: ]FOO      .... local1 ] local2 ....  ;

: TEST [ do-something ]FOO ;  ought to work just fine.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Julian V. Noble  
View profile
 More options Aug 22 2006, 11:02 am
Newsgroups: comp.lang.forth
From: "Julian V. Noble" <j...@virginia.edu>
Date: Tue, 22 Aug 2006 11:02:36 -0400
Local: Tues, Aug 22 2006 11:02 am
Subject: Re: RfD - Enhanced local variable syntax (long)

Marcel Hendrix wrote:
> stephen...@mpeforth.com (Stephen Pelc) writes Re: RfD - Enhanced local variable syntax (long)

>> On Mon, 21 Aug 2006 21:03:32 GMT, m...@iae.nl (Marcel Hendrix) wrote:

        [ snip ]

>>>> But to get there someone has to go through the process of
>>>> standardising TO and friends for FLOATS. I'm not prepared to
>>>> do that yet. There isn't an FVALUE yet, so over to ... you?

>>> I wouldn't live without it, but if I'm the only one, why standardize?

>> Chicken and egg - there's no champion. I'm with you on wanting
>> FVALUE, but we don't have a reference implementation with a long
>> history. Perhaps someone can explain why it didn't make it into ANS.

> FVALUE has always been in tForth and iForth. I meant that for a standard
> there must at least be two conflicting implementations.

> -marcel

I note that Win32Forth has FVALUE and FTO . Gforth does not.

I doubt whether Win32Forth's version conflicts with Marcel's in
its usage.

--
Julian V. Noble
Professor Emeritus of Physics
University of Virginia


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
GerryJ  
View profile
 More options Aug 22 2006, 1:03 pm
Newsgroups: comp.lang.forth
From: "GerryJ" <ge...@jackson9000.fsnet.co.uk>
Date: 22 Aug 2006 10:03:31 -0700
Local: Tues, Aug 22 2006 1:03 pm
Subject: Re: RfD - Enhanced local variable syntax (long)

This misses the point of what I was trying to say. I was responding to
a statement by Marcel Hendrix which said:

> Because @ and ! would *require* local variables to *have* an address.
> They could not live in registers then (unless you redefine @ ! +! F@ F!
> MOVE ERASE ... ). TO hides this detail. *I* like it :-)

He states that because some implementations of locals puts them in
registers, which cannot have an address, local variables that leave
their address on the stack must not be included in the standard. I
disagree with that.

As other implementations implement locals in memory, their local
variables could leave an address on the stack. Notwithstanding the aim
to  encapsulate existing common practice I think assuming locals will
be implemented in registers is going too far if it means a useful bit
of functionality cannot be included in the standard. After all if local
variables leaving an address on the stack were part of the standard,
compilers that would otherwise allocate them to registers could place
them in memory and the programmer would have to take the performance
hit. Presumably compilers that use registers for locals must have a
mechanism for using memory anyway as they must run out of registers in
some cases.

Anyway if you start calling them local values in your proposal the
problem goes away and everybody is happy.

Gerry


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcel Hendrix  
View profile
 More options Aug 22 2006, 3:28 pm
Newsgroups: comp.lang.forth
From: m...@iae.nl (Marcel Hendrix)
Date: Tue, 22 Aug 2006 19:28:20 GMT
Local: Tues, Aug 22 2006 3:28 pm
Subject: Re: RfD - Enhanced local variable syntax (long)