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.
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
<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
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
<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.
> 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" ;-)
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?
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.
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.
>> 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
Stephen Pelc wrote: > On 21 Aug 2006 14:15:00 -0700, "GerryJ" > <ge...@jackson9000.fsnet.co.uk> wrote:
> >Why not call them local values then? Differences between different > >types of variables is inconsistent and that is *bad* in any language.
> You have a point.
> >Anyway, while standards have to implementable, an implementation > >driving the standard is a bit like the tail wagging the dog.
> Not so. At least during the ANS Forth process, it was emphasised > to us by the upper level of ANS that a standard should (where > possible) encapsulate existing common practice. The brace notation > without local buffers has been idependently implemented on several > systems.
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.