Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
RfD: Enhanced local variable syntax
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 1 - 25 of 49 - Collapse all  -  Translate all to Translated (View all originals)   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
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter Knaggs  
View profile  
 More options Jul 11 2007, 12:55 pm
Newsgroups: comp.lang.forth
From: Peter Knaggs <pkna...@bournemouth.ac.uk>
Date: Wed, 11 Jul 2007 17:55:06 +0100
Local: Wed, Jul 11 2007 12:55 pm
Subject: RfD: Enhanced local variable syntax
Stephen Pelc - 7 June 2007

20070607 Wordsmithing. Corrected reference implementation.
20060822 Added explanatory text.
          Corrected reference implementation.
          Updated ambiguous conditions.

Problem
=======
1) The current LOCALS| ... | notation explicitly forces all locals
    to be initialised from the data stack.
2) The current LOCALS| ... | notation defines locals in reverse
    order to the normal stack notation.
3) When programming large applications, especially those interfacing
    with a host operating system, there is a frequent need for temporary
    buffers.
4) Current implementations show that creation and destruction of
    local buffers are much faster than using ALLOCATE (14.6.1.0707)
    and FREE (14.6.1.1605).

Solution
========
Base version
------------
The following syntax for local arguments and local variables is
proposed. The sequence:

   { ni1 ni2 ... | lv1 lv2 ... -- o1 o2 ... }

defines local arguments, local variables, and outputs. The local
arguments are automatically initialised from the data stack on
entry, the rightmost being taken from the top of the data stack.
Local arguments and local variables can be referenced by name within
the word during compilation. The output names are dummies to allow
a complete stack comment to be generated.

The items between { and | are local arguments.
The items between | and -- are local variables or buffers.
The items between -- and } are outputs for formal comments only.

The outputs are provided in the notation so that complete stack
comments can be produced. However, all text between -- and } is
ignored. The facility is there to permit the notation to form a
complete stack comment. This eases documentation and current
users of the notation like this facility.

Local arguments and variables return their values when referenced,
and must be preceded by TO to perform a store.

Local buffers may be defined in the form:

   arr[ <expr> ]

Any name ending in the '[' character will be treated as a buffer,
the expression up to the terminating ']' will be interpreted to
provide the size of the buffer. Local buffers only return their base
address, all operators such as TO generate an ambiguous condition.

In the example below, a and b are local arguments, a+b and a*b are
local variables, and arr[ is a 10 byte local buffer.

: foo  { a b | a+b a*b arr[ 10 ] -- }
   a b + to a+b
   a b * to a*b
   cr a+b .  a*b .
   arr[ 10 erase
   s" Hello" arr[ swap cmove
;

Local types
-----------
Some current Forth systems use indicators to define local variables
of sizes other than a cell. It is proposed that any name ending in a ':'
(colon) be reserved for this use.

: foo  { a b | F: f1 F: f2 -- c }
   ...
;

Discussion
==========
The '|' (ASCII 0x7C) character is widely used as the separator
between local arguments and local variables. Other characters
accepted in current Forth implementations are '\' (ASCII 0x5C) and
'¦' (ASCII 0xA6).. Since the ANS standard is defined in terms of
7 bit ASCII, and with regard to internationalisation, we propose only
to consider the '|' and '\' characters further. Only recognition of
the '|' separator is mandatory.

The use of local types is contentious as they only become useful
if TO is available for these. In practice, some current systems
permit TO to be used with floats (children of FVALUE) and other
data types. Such systems often provide additional operators such
as +TO (add from stack to item) for children of VALUE and FVALUE.
Standardisation of operators with (for example) floats needs to
be done before the local types extension can be incorporated into
Forth200x. Apart from forcing allocation of buffer space, no
additional functionality is provided by local types that cannot
be obtained using local buffers. More preparatory standardisation
needs to be done before local types can be standardised.

Apart from { (brace) itself, the proposal introduces one new
word BUILDLV. The definition of this word is designed for future
enhancements, e.g. more local data types, without having to
introduce more new words.

It has been noted that one widely used implementation uses brace
for multi line comments. However, inspection of the vendor's code
shows that this use only occurs during interpretation. The
interpretation semantics of brace in this proposal are undefined
in order for that implementation to coexist with this proposal.

Proposal
========

13.3 and 13.4
Add "and BUILDLV" where (LOCAL) is referenced.

13.6.2.xxxx {
brace LOCAL EXT

Interpretation: Interpretation semantics for this word are undefined.

Compilation:
( "<spaces>arg1" ... "<spaces>argn" | "<spaces>lv1" ... "<spaces>lvn" -- )

Create up to eight local arguments by repeatedly skipping leading
spaces, parsing arg, and executing 13.6.2.yyyy BUILDLV. The list of
local arguments to be defined is terminated by "|", "--" or "}".
Append the run-time semantics for local arguments given below to the
current definition. If a space delimited '|' is encountered, create
up to eight local variables or buffers by repeatedly skipping
leading spaces, parsing lv, and executing 13.6.2.yyyy BUILDLV. The
list of local variables and buffers to be defined is terminated by
"--" or "}". Append the run-time semantics for local variables and
local buffers given below to the current definition. If "--" has
been encountered, further text between  "--" and } is ignored.

Local buffers have names that end in the '[' character. They define
their size by parsing the text string up to the next ']' character,
and passing that string to 7.6.1.1360 EVALUATE to obtain the size
of the storage in address units.

Local argument run-time: ( x1 ... xn -- )
Local variable run-time: ( -- )
Local buffer run-time: ( -- )

Initialize up to eight local arguments as described in 13.6.2.yyyy
BUILDLV. Local argument arg1 is initialized with x1, arg2 with x2 up
to argn from xn, which is on the top of the data stack. When
invoked, each local argument will return its value. The value
of a local argument may be changed using 13.6.1.2295 TO.

Initialize up to eight local variables or local buffers as described
in 13.6.2.yyyy BUILDLV. The initial contents of local variables and
local buffers are undefined. When invoked, each local variable
returns its value. The value of a local variable may be changed
using 13.6.1.2295 TO. The size of a local variable is a cell.
When invoked, each local buffer will return its address. The user
may make no assumption about the order and contiguity of local
variables and buffers in memory.

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) { ... } is declared more than once in a word.
d) Parsing units '|', ']', '--' and '}' are not white space delimited.

13.6.2.yyyy BUILDLV
build-l-v LOCAL EXT

Interpretation: Interpretation semantics for this word are undefined.

Execution: ( c-addr u +n mode -- )
When executed during compilation, BUILDLV passes a message to the
system identifying a new local argument whose definition name is
given by the string of characters identified by c-addr u. The size
of the data item is given by +n address units, and the mode
identifies the construction required as follows:
     0 - finish construction of initialisation and data storage
         allocation code. C-addr and u are ignored. +n is 0
         (other values are reserved for future use).
     1 - identify a local argument, +n = cell
     2 - identify a local variable, +n = cell
     3 - identify a local buffer, +n = storage required.
    4+ - reserved for future use
   -ve - implementation specific values

The result of executing BUILDLV during compilation of a definition
is to create a set of named local arguments, variables and/or
buffers, each of which is a definition name, that only have
execution semantics within the scope of that definition's source.

local argument execution: ( -- x )
Push the local argument's value, x, onto the stack. The local
argument's value is initialized as described in 13.6.2.xxxx { and may be
changed by preceding the local argument's name with TO.

local variable execution: ( -- x )
Push the local variable's value, x, onto the stack. The local
variable is not initialised. The local variable's value may be
changed by preceding the local variable's name with TO.

local buffer execution: ( -- a-addr )
Push the local buffer's address, a-addr, onto the stack. The address
is aligned as in 3.3.3.1. The contents of the buffer are not
initialised.

Note: This word does not have special compilation semantics in the
usual sense because it provides access to a system capability for
use by other user-defined words that do have them. However, the
locals facility as a whole and the sequence of messages passed
defines specific usage rules with semantic implications that are
described in detail in section 13.3.3 Processing locals.

Note: This word is not intended for direct use in a definition to
declare that definition's locals. It is instead used by system or
user compiling words. These compiling words in turn define their
own syntax, and may be used directly in definitions to declare
locals. In this context, the syntax for BUILDLV is defined in terms
of a sequence of compile-time messages and is described in detail
in section 13.3.3 Processing locals.

Note: The LOCAL EXT word set modifies the syntax and semantics of
6.2.2295 TO as defined in the Core Extensions word set.

See: 3.4 The Forth text interpreter

Ambiguous conditions:
   a local argument, variable or buffer is executed while in
   interpretation state.

Reference implementation
=========================
(currently untested)

: TOKEN         \ -- caddr u
\ Get the next space delimited token from the input stream.
   BL PARSE
;

: LTERM?        \ caddr u -- flag
\ Return true if the string caddr/u is "--" or "}"
   2DUP S" --" COMPARE 0= >R
   S" }" COMPARE 0=  R> OR
;

: LBSIZE        \ -- +n
\ Parse
...

read more »


 
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.
Anton Ertl  
View profile  
 More options Jul 14 2007, 9:58 am
Newsgroups: comp.lang.forth
From: an...@mips.complang.tuwien.ac.at (Anton Ertl)
Date: Sat, 14 Jul 2007 13:58:59 GMT
Local: Sat, Jul 14 2007 9:58 am
Subject: Re: RfD: Enhanced local variable syntax

Peter Knaggs <pkna...@bournemouth.ac.uk> writes:
>Stephen Pelc - 7 June 2007
>'¦' (ASCII 0xA6)

That's not an ASCII character, it's Latin-1.

>Only recognition of
>the '|' separator is mandatory.

Good.

>The use of local types is contentious as they only become useful
>if TO is available for these.

Not really; I generally use locals (including FP locals) without using
TO.

Also, extending TO to support FP locals is easy with the proposed
rewording of TO.

> In practice, some current systems
>permit TO to be used with floats (children of FVALUE) and other
>data types. Such systems often provide additional operators such
>as +TO (add from stack to item) for children of VALUE and FVALUE.
>Standardisation of operators with (for example) floats needs to
>be done before the local types extension can be incorporated into
>Forth200x.

If by "operator" you mean words like +TO, let the proponent of such
a word worry about that.

If you mean operators like TO, and you don't want to propose it, don't
do it; I'm sure Marcel Hendrix will step up.  If you want to propose
TO for FP locals, I don't see any hurdle.

>Apart from { (brace) itself, the proposal introduces one new
>word BUILDLV. The definition of this word is designed for future
>enhancements, e.g. more local data types, without having to
>introduce more new words.

The intention behind BUILDLV is good, but I find the design extremely
ugly (see, e.g., <2006Aug23.225...@mips.complang.tuwien.ac.at> for a
detailed critique).  Moreover, I don't think it buys much, if
anything: nobody is going to use it, just as almost nobody is
currently using "(LOCAL)".  So while one could design a cleaner
replacement for BUILDLV, I don't think it is worth the effort, and the
proposal will be more attractive to implementors and not any less
attractive to programmers if you just leave BUILDLV and its
replacement away.

- 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 2007: http://www.complang.tuwien.ac.at/anton/euroforth2007/


 
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.
Bruce McFarling  
View profile  
 More options Jul 14 2007, 5:27 pm
Newsgroups: comp.lang.forth
From: Bruce McFarling <agil...@netscape.net>
Date: Sat, 14 Jul 2007 14:27:15 -0700
Local: Sat, Jul 14 2007 5:27 pm
Subject: Re: RfD: Enhanced local variable syntax
On Jul 11, 12:55 pm, Peter Knaggs <pkna...@bournemouth.ac.uk> wrote:

Local variables are not local variables, they are unintitialized local
values. Returning an address for them to be used as actual local
variables would eliminate the question of TO altogether.


 
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.
Ed  
View profile  
 More options Jul 15 2007, 12:44 am
Newsgroups: comp.lang.forth
From: "Ed" <nos...@invalid.com>
Date: Sun, 15 Jul 2007 14:44:32 +1000
Local: Sun, Jul 15 2007 12:44 am
Subject: Re: RfD: Enhanced local variable syntax

"Peter Knaggs" <pkna...@bournemouth.ac.uk> wrote in message news:46950B6A.9050605@bournemouth.ac.uk...
> Stephen Pelc - 7 June 2007

> ...
> Apart from { (brace) itself, the proposal introduces one new
> word BUILDLV. The definition of this word is designed for future
> enhancements, e.g. more local data types, without having to
> introduce more new words.
> ...

I would suggest there is no necessity to have BUILDLV as a word
within the standard.  The standard only needs to define the syntax
used by local variables.  BUILDLV has to do with implementation.

> Any name ending in the '[' character will be treated as a buffer,
> the expression up to the terminating ']' will be interpreted to
> provide the size of the buffer.
> ...

As others previously noted, embedding an operator  [  within a
name is contrary to forth's simple parsing.  There must be a
better way.

 
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.
Coos Haak  
View profile  
 More options Jul 15 2007, 5:55 am
Newsgroups: comp.lang.forth
From: Coos Haak <chfo...@hccnet.nl>
Date: Sun, 15 Jul 2007 11:55:19 +0200
Local: Sun, Jul 15 2007 5:55 am
Subject: Re: RfD: Enhanced local variable syntax
Op Sun, 15 Jul 2007 14:44:32 +1000 schreef Ed:

> As others previously noted, embedding an operator  [  within a
> name is contrary to forth's simple parsing.  There must be a
> better way.

I can't follow you. The word would be parsed, perform its semantics and set
STATE to zero. ; follows exactly the same recipe.

--
Coos

CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html


 
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.
Ed  
View profile  
 More options Jul 15 2007, 10:40 pm
Newsgroups: comp.lang.forth
From: "Ed" <nos...@invalid.com>
Date: Mon, 16 Jul 2007 12:40:16 +1000
Local: Sun, Jul 15 2007 10:40 pm
Subject: Re: RfD: Enhanced local variable syntax

"Coos Haak" <chfo...@hccnet.nl> wrote in message news:iynuqnpgen7w$.c7vdhnd2ofx9.dlg@40tude.net...
> Op Sun, 15 Jul 2007 14:44:32 +1000 schreef Ed:

> > As others previously noted, embedding an operator  [  within a
> > name is contrary to forth's simple parsing.  There must be a
> > better way.

> I can't follow you. The word would be parsed, perform its semantics and set
> STATE to zero. ; follows exactly the same recipe.

The proposal calls for locals buffer names to be defined in the form:

    bufname[

where   [  is stripped off, leaving the actual name  'bufname'

That's contrary to forth practice where names are space delimited.
The first time I saw this syntax being used, I thought there existed
a word in the dictionary called  'bufname['  but try as I might I could
not find it.

IMO one of the nicest features of forth is it's simple syntax:
names or numbers separated by spaces.  Let's keep it that way.


 
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.
Jerry Avins  
View profile  
 More options Jul 15 2007, 11:36 pm
Newsgroups: comp.lang.forth
From: Jerry Avins <j...@ieee.org>
Date: Sun, 15 Jul 2007 23:36:56 -0400
Local: Sun, Jul 15 2007 11:36 pm
Subject: Re: RfD: Enhanced local variable syntax

Ed wrote:

   ...

> As others previously noted, embedding an operator  [  within a
> name is contrary to forth's simple parsing.  There must be a
> better way.

Others? Which others? '[' is a character like any other. It would be
pointless, even silly, to define
  : ][ ( -- ) ." Look Ma, an Apple II!" CR ;
but it should work an any Forth system.

Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯


 
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.
Jerry Avins  
View profile  
 More options Jul 15 2007, 11:40 pm
Newsgroups: comp.lang.forth
From: Jerry Avins <j...@ieee.org>
Date: Sun, 15 Jul 2007 23:40:35 -0400
Local: Sun, Jul 15 2007 11:40 pm
Subject: Re: RfD: Enhanced local variable syntax

Ed wrote:

   ...

> IMO one of the nicest features of forth is it's simple syntax:
> names or numbers separated by spaces.  Let's keep it that way.

I apparently misunderstood again. Yes: Let's keep it that way.

Jerry
--
L'etat n'a pas besoin des savants: Robespierre, on Lavoisier's death.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯


 
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.
Gerry  
View profile  
 More options Jul 16 2007, 2:53 am
Newsgroups: comp.lang.forth
From: Gerry <ge...@jackson9000.fsnet.co.uk>
Date: Sun, 15 Jul 2007 23:53:14 -0700
Local: Mon, Jul 16 2007 2:53 am
Subject: Re: RfD: Enhanced local variable syntax
On 14 Jul, 22:27, Bruce McFarling <agil...@netscape.net> wrote:

> On Jul 11, 12:55 pm, Peter Knaggs <pkna...@bournemouth.ac.uk> wrote:

> Local variables are not local variables, they are unintitialized local
> values. Returning an address for them to be used as actual local
> variables would eliminate the question of TO altogether.

I agree. I remember pointing this out last year. A standard should be
precise in its use of terminology. Up to now I believe that the word
variable in Forth means an object that leaves its address on the stack
when invoked. Indeed the standard states in 2.1

" Variable: a named region of data space located and accessed by its
memory address."

The proposed local variables do not do that and so should be called
local values.

I know this is nit picking but a standard needs its nits to be picked.

Gerry


 
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.
Anton Ertl  
View profile  
 More options Jul 16 2007, 4:25 am
Newsgroups: comp.lang.forth
From: an...@mips.complang.tuwien.ac.at (Anton Ertl)
Date: Mon, 16 Jul 2007 08:25:25 GMT
Local: Mon, Jul 16 2007 4:25 am
Subject: Re: RfD: Enhanced local variable syntax

Gerry <ge...@jackson9000.fsnet.co.uk> writes:
>" Variable: a named region of data space located and accessed by its
>memory address."

>The proposed local variables do not do that and so should be called
>local values.

Forth-94 just calls them "locals", except in 13.3.2, where "local
variables" occurs.  "Local value" does not occur (at least not in
Chapter 13).

- 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 2007: http://www.complang.tuwien.ac.at/anton/euroforth2007/


 
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.
Gerry  
View profile  
 More options Jul 17 2007, 6:46 am
Newsgroups: comp.lang.forth
From: Gerry <ge...@jackson9000.fsnet.co.uk>
Date: Tue, 17 Jul 2007 03:46:16 -0700
Local: Tues, Jul 17 2007 6:46 am
Subject: Re: RfD: Enhanced local variable syntax
On 16 Jul, 09:25, an...@mips.complang.tuwien.ac.at (Anton Ertl) wrote:

> Gerry <ge...@jackson9000.fsnet.co.uk> writes:
> >" Variable: a named region of data space located and accessed by its
> >memory address."

> >The proposed local variables do not do that and so should be called
> >local values.

> Forth-94 just calls them "locals", except in 13.3.2, where "local
> variables" occurs.  "Local value" does not occur (at least not in
> Chapter 13).

Yes it looks like the original technical committee recognised the
problem of using the term local variables and avoided it except for
the 1 slip up that you noted. I don't know what you could call them
except local values which does sound a bit awkward.

Gerry


 
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.
Peter Knaggs  
View profile  
 More options Jul 21 2007, 5:40 am
Newsgroups: comp.lang.forth
From: Peter Knaggs <pkna...@bournemouth.ac.uk>
Date: Sat, 21 Jul 2007 10:40:31 +0100
Local: Sat, Jul 21 2007 5:40 am
Subject: Re: RfD: Enhanced local variable syntax

What syntax would you like, I can think of two alternatives:

        20 buffer: bufname      or      bufname [ 20 ALLOT ]

both of which would make the parsing of locals considerably more complex.

As we are talking about a standard, we have to consider what already
exists, not what we would like to exist. There are systems out there
which have been using the bufname[ 20 ] format for many years.

--
Peter Knaggs


 
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.
Andrew Haley  
View profile  
 More options Jul 21 2007, 6:14 am
Newsgroups: comp.lang.forth
From: Andrew Haley <andre...@littlepinkcloud.invalid>
Date: Sat, 21 Jul 2007 10:14:34 -0000
Local: Sat, Jul 21 2007 6:14 am
Subject: Re: RfD: Enhanced local variable syntax

Most of this proposal makes good sense, but items 3 and 4 make no
sense at all.  We can already use ALLOT to create local buffers, and
Forth stacks are usually (traditionally?) too small to be used for
such things.  Also, forcing buffer names to have a special syntax is
very non-Forth.  So what is the application use for these words?  Do
they have one?

Andrew.


 
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 Jul 21 2007, 6:20 am
Newsgroups: comp.lang.forth
From: m...@iae.nl (Marcel Hendrix)
Date: Sat, 21 Jul 2007 12:20:50 +0200
Local: Sat, Jul 21 2007 6:20 am
Subject: Re: RfD: Enhanced local variable syntax
Peter Knaggs <pkna...@bournemouth.ac.uk> writes Re: RfD: Enhanced local variable syntax
[..]

> What syntax would you like, I can think of two alternatives:
>    20 buffer: bufname      or      bufname [ 20 ALLOT ]
> both of which would make the parsing of locals considerably more complex.

What's wrong with your last one?

Let's see ..

        bufname buffer 20
or      
        bufname [] 20

or      bufname [ 20 CELLS ]

.. where buffer, [] or [ is recognized by LOCALS| and executed instead of made
into a local. The BUFFER modifier word would then simply modify the allocation
size of the latest local.

I don't see that '[' would make the locals parser 'considerably more complex.'

-marcel


 
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.
Elizabeth D Rather  
View profile  
 More options Jul 21 2007, 2:41 pm
Newsgroups: comp.lang.forth
From: Elizabeth D Rather <erather...@forth.com>
Date: Sat, 21 Jul 2007 08:41:35 -1000
Local: Sat, Jul 21 2007 2:41 pm
Subject: Re: RfD: Enhanced local variable syntax

Peter Knaggs wrote:
> Ed wrote:
...
>> IMO one of the nicest features of forth is it's simple syntax:
>> names or numbers separated by spaces.  Let's keep it that way.

> What syntax would you like, I can think of two alternatives:

>     20 buffer: bufname    or    bufname [ 20 ALLOT ]

> both of which would make the parsing of locals considerably more complex.

> As we are talking about a standard, we have to consider what already
> exists, not what we would like to exist. There are systems out there
> which have been using the bufname[ 20 ] format for many years.

Horrors, not 'buffer:' since that name is used in Open Firmware, FORTH,
Inc. products, OTA, and probably others as equivalent to:

: BUFFER: ( n -- )   CREATE ALLOT ;

Trivial syntactic sugar, to be sure, but widely used and very popular.

Cheers,
Elizabeth

--
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310-491-3356
5155 W. Rosecrans Ave. #1018  Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================


 
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.
Ed  
View profile  
 More options Jul 22 2007, 12:09 am
Newsgroups: comp.lang.forth
From: "Ed" <nos...@invalid.com>
Date: Sun, 22 Jul 2007 14:09:55 +1000
Local: Sun, Jul 22 2007 12:09 am
Subject: Re: RfD: Enhanced local variable syntax

Assuming there is clear support for such a change (and this needs to
be established) any syntax that follows forth norms should suffice.
Name last is simple and commonplace in forth, so perhaps:

    [ alignment/size ]  name

Given the parser is already looking for a delimiter/operator e.g.  --  }
then adding  [  should not be difficult?

> As we are talking about a standard, we have to consider what already
> exists, not what we would like to exist. There are systems out there
> which have been using the bufname[ 20 ] format for many years.

IMO standards have an obligation to choose best practice because
all forth users are affected, including forth users of the future.

 
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.
Ed  
View profile  
 More options Jul 23 2007, 7:00 am
Newsgroups: comp.lang.forth
From: "Ed" <nos...@invalid.com>
Date: Mon, 23 Jul 2007 21:00:35 +1000
Local: Mon, Jul 23 2007 7:00 am
Subject: Re: RfD: Enhanced local variable syntax

"Ed" <nos...@invalid.com> wrote in message news:f7uled$mf$1@news-01.bur.connect.com.au...
> ...
> Assuming there is clear support for such a change (and this needs to
> be established) any syntax that follows forth norms should suffice.
> Name last is simple and commonplace in forth, so perhaps:

>     [ alignment/size ]  name

> Given the parser is already looking for a delimiter/operator e.g.  --  }
> then adding  [  should not be difficult?

Not difficult as it turns out.  Here are the changes to the reference
implementation needed to implement this scheme (also untested :)

: LB?           \ caddr u -- flag
   S" [" COMPARE 0=
;

\ changes to definition {
       ELSE                              \ variable or buffer
         2DUP LB?
         IF  2DROP  LBSIZE  TOKEN  ROT  3  ELSE  CELL 2  THEN
       THEN


 
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 Jul 23 2007, 8:35 am
Newsgroups: comp.lang.forth
From: Alex McDonald <b...@rivadpm.com>
Date: Mon, 23 Jul 2007 05:35:31 -0700
Local: Mon, Jul 23 2007 8:35 am
Subject: Re: RfD: Enhanced local variable syntax
On Jul 11, 5:55 pm, Peter Knaggs <pkna...@bournemouth.ac.uk> wrote:

[snipped]

This RfD and the solutions discussed elsewhere in this thread lead me
to conclude that, as LOCALS (both { and LOCALS|) already demand an
alternative parse to the traditional Forth parse of find and compile,
neither is amenable to further simple expansion due to the
increasingly bizarre extensions of syntax being put forward. I would
prefer to see a straightforward and clean parse based, as far as is
possible, on the current Forth model, and not a parse that /by design/
requires alternative meanings or special syntaxes for standard Forth
words that are not available outside of LOCALS use (i.e. [ n ] ARR or
ARR[ n ] for CREATE ARR n ALLOT; or f: for FLOAT values).

I realise that Win32Forth is guilty of the use of trailing : for OOP
class methods, and [ ] for late binding; that's a feature of NEON/MOPS
that I, for one, dislike, as it makes complex something that should be
simple. This proposal on a NEON/MOPS system would allow

: f: { f: seconds | } seconds f: rocket ;

Three seperate meanings of f: (a word, a float definition and a method
invocation respectively). Even on simpler, non-NEON/MOPS systems,
there would be two meanings. Best not to repeat that mistake.

I believe { } needs abandoned as a standards proposal, or fixed in its
current usage, and some other design should take its place. I can't
support this RfD in its current form, nor the alternative proposals it
has spawned.

--
Regards
Alex McDonald


 
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.
Anton Ertl  
View profile  
 More options Jul 23 2007, 8:56 am
Newsgroups: comp.lang.forth
From: an...@mips.complang.tuwien.ac.at (Anton Ertl)
Date: Mon, 23 Jul 2007 12:56:15 GMT
Local: Mon, Jul 23 2007 8:56 am
Subject: Re: RfD: Enhanced local variable syntax

One difference is that the Neon stuff can occur anywhere in Forth
code, whereas Stephen's funky buffer syntax can only occur inside a
locals definition, i.e., between { and }.  And there syntax is treated
non-uniformly already, as all occuring words are defined, except },
--, and | (and the situation with LOCALS| is similar).

I think the Neon stuff is a mistake, because AFAIK one cannot tick or
POSTPONE the words ending in ":".

In that sense locals are a mistake irrespective of syntax, because you
cannot tick or POSTPONE a local.  However, since locals are just a
convenience for stuff that one can also do without too much ado in
other ways (i.e., using the stacks), this has not turned out to be a
problem (I never find myself wishing that I could tick or POSTPONE a
local).

Concerning the { syntax, one can POSTPONE { itself; this is a parsing
word, so if one cannot also POSTPONE the stuff it parses, that's
nothing unusual.

> This proposal on a NEON/MOPS system would allow

>: f: { f: seconds | } seconds f: rocket ;

Actually the present proposal does not cover FP locals and does not
propose "f:".  It's surprising that the heaviest user of FP locals I
know (Marcel Hendrix) has not complained about that, but maybe his
plan is to stay away from "{" anyway; he seems to enjoy defining the
locals in the wrong order.

>Three seperate meanings of f: (a word, a float definition and a method
>invocation respectively). Even on simpler, non-NEON/MOPS systems,
>there would be two meanings. Best not to repeat that mistake.

However, assuming that we get f: eventually: That's not so unusual,
and not a problem, so I don't see it as a mistake.  E.g., I can also
write:

: SWAP SWAP ;

and the two occurences of SWAP have different meanings.

>I believe { } needs abandoned as a standards proposal, or fixed in its
>current usage, and some other design should take its place.

Given the present relatively wide acceptance of {, standardizing that
is probably the best chance we have of getting more featureful locals
(e.g., FP locals).  I don't think there is a realistic chance that
another syntax will succeed if { fails.  And certainly not if no one
makes a proposal for such an alternative syntax.

- 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 2007: http://www.complang.tuwien.ac.at/anton/euroforth2007/


 
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 Jul 23 2007, 1:02 pm
Newsgroups: comp.lang.forth
From: m...@iae.nl (Marcel Hendrix)
Date: Mon, 23 Jul 2007 19:02:48 +0200
Local: Mon, Jul 23 2007 1:02 pm
Subject: Re: RfD: Enhanced local variable syntax
an...@mips.complang.tuwien.ac.at (Anton Ertl) writes Re: RfD: Enhanced local variable syntax
[..]

> Actually the present proposal does not cover FP locals and does not
> propose "f:".  It's surprising that the heaviest user of FP locals I
> know (Marcel Hendrix) has not complained about that, but maybe his
> plan is to stay away from "{" anyway; he seems to enjoy defining the
> locals in the wrong order.

No, I will implement '{', why should I resist that?

AFAIK, at the moment '{' is not standard, so I am amazed to get such heavy
flak each time I for once decide to use a standard Forth construct :-)

[ I do not complain that F: is missing in the proposal because I do not
  like the looks of it. I remember how to use things by reconstructing how
  they work (This means I never learned to tie my shoelaces properly because
  the Kindergarten teacher didn't succeed in explaining the mathematics,
  the WHY, of this fantastic trick to me). For me, there is no logic in the '{'
  proposal because local initializers must be popped off the stack, which
  means the logical arrangement of names is first-local-connects-to-TOS.
  Floats are on a different stack, so they shouldn't mix with integer locals.
  Besides that, I have many more types of locals (complex, double-double,
  long integer, strings). I could start using '{', but it wouldn't make
  my code portable. ]

In eForth64 I have now added the line:

: PARAMS| ( "names |" -- )
        lp@ @ >S
        ['] (LOCAL) 1 MAKE-LOCALS  
        S> INIT-LOCALS2, ; IMMEDIATE

... and as soon as the standard is final I will do a SYNONYM (or something)
and create a '{' for those programmers that absolutely need it.

-marcel


 
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.
Anton Ertl  
View profile  
 More options Jul 23 2007, 4:09 pm
Newsgroups: comp.lang.forth
From: an...@mips.complang.tuwien.ac.at (Anton Ertl)
Date: Mon, 23 Jul 2007 20:09:11 GMT
Local: Mon, Jul 23 2007 4:09 pm
Subject: Re: RfD: Enhanced local variable syntax

m...@iae.nl (Marcel Hendrix) writes:
>an...@mips.complang.tuwien.ac.at (Anton Ertl) writes Re: RfD: Enhanced local variable syntax
>[..]
>[ I do not complain that F: is missing in the proposal because I do not
>  like the looks of it.

Would you like to have standard FP locals?  Then this is a chance to
get them.

>  For me, there is no logic in the '{'
>  proposal because local initializers must be popped off the stack, which
>  means the logical arrangement of names is first-local-connects-to-TOS.

The logic is that the locals are in the same order as in the standard
stack notation, i.e., TOS is rightmost.

>  Floats are on a different stack, so they shouldn't mix with integer locals.

Even if you have a separate FP stack, there is no reason not to mix
the FP locals definitions with the cell locals definitions.  Do you
think that there should be apartheid between FPs and cells in the rest
of the code?  E.g., don't have any words that perform both integer and
FP operations?

>  Besides that, I have many more types of locals (complex, double-double,
>  long integer, strings).

You could suggest additional types for the proposal.

> I could start using '{', but it wouldn't make
>  my code portable. ]

If you use { and F:, this at least makes your code portable to Gforth,
whereas FLOCALS| is not portable anywhere.

>In eForth64 I have now added the line:

>: PARAMS| ( "names |" -- )
>    lp@ @ >S
>    ['] (LOCAL) 1 MAKE-LOCALS  
>    S> INIT-LOCALS2, ; IMMEDIATE

>... and as soon as the standard is final I will do a SYNONYM (or something)
>and create a '{' for those programmers that absolutely need it.

Will the SYNONYM ensure that the closing word is "}", and that "|" and
"--" do what they should?

- 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 2007: http://www.complang.tuwien.ac.at/anton/euroforth2007/


 
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 Jul 24 2007, 9:39 am
Newsgroups: comp.lang.forth
From: Alex McDonald <b...@rivadpm.com>
Date: Tue, 24 Jul 2007 06:39:37 -0700
Local: Tues, Jul 24 2007 9:39 am
Subject: Re: RfD: Enhanced local variable syntax
On Jul 23, 1:56 pm, an...@mips.complang.tuwien.ac.at (Anton Ertl)
wrote:

Ye, but adding to the problem inside { } appears to be a mistake. The
funky buffer allocations and the reservation for words ending in : are
adding syntactic sugar to CREATE ALLOT and VALUE/FVALUE and friends.
It's as though we're proposing a completely separate language in its
own local universe that we escape into through { } .

Order notwithstanding, the proposal reserves words terminating in :
for types.

> >Three seperate meanings of f: (a word, a float definition and a method
> >invocation respectively). Even on simpler, non-NEON/MOPS systems,
> >there would be two meanings. Best not to repeat that mistake.

> However, assuming that we get f: eventually: That's not so unusual,
> and not a problem, so I don't see it as a mistake.  E.g., I can also
> write:

> : SWAP SWAP ;

> and the two occurences of SWAP have different meanings.

The three F:s have quite separate meanings; and syntax, given that two
of them parse. My example is contrived; but reserving /any/ character
in Forth and assigning meaning to it is just not on, imho. It seems
daft to assign semantics to syntax. Win32Forth has already committed
this mistake; and at least your second SWAP SWAPs, and is clear in its
intention.

> >I believe { } needs abandoned as a standards proposal, or fixed in its
> >current usage, and some other design should take its place.

> Given the present relatively wide acceptance of {, standardizing that
> is probably the best chance we have of getting more featureful locals
> (e.g., FP locals).  I don't think there is a realistic chance that
> another syntax will succeed if { fails.  And certainly not if no one
> makes a proposal for such an alternative syntax.

I'm not smart enough to do it, although I see it needs to be done.

Don't take it from this a request for a veto. It's right that a simple
majority should suffice to carry an RfD.


 
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 Jul 24 2007, 10:58 am
Newsgroups: comp.lang.forth
From: Alex McDonald <b...@rivadpm.com>
Date: Tue, 24 Jul 2007 07:58:08 -0700
Local: Tues, Jul 24 2007 10:58 am
Subject: Re: RfD: Enhanced local variable syntax
On Jul 24, 2:39 pm, Alex McDonald <b...@rivadpm.com> wrote:

> Don't take it from this a request for a veto. It's right that a simple
> majority should suffice to carry an RfD.

I meant CfV, not the RfD stages.

--
Regards
Alex McDonald


 
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.
Elizabeth D Rather  
View profile  
 More options Jul 24 2007, 1:57 pm
Newsgroups: comp.lang.forth
From: Elizabeth D Rather <erather...@forth.com>
Date: Tue, 24 Jul 2007 07:57:09 -1000
Local: Tues, Jul 24 2007 1:57 pm
Subject: Re: RfD: Enhanced local variable syntax
Alex McDonald wrote:

...

> Don't take it from this a request for a veto. It's right that a simple
> majority should suffice to carry an RfD.

[Accepting your correction that you mean a CfV]  No, it's not right.
ANSI and ISO rules all require "consensus", which means far more than a
simple majority.

During the Forth94 process we required all proposals that had more than
2 'no' votes to go back to committee for resolution.  Broad consensus is
required to ensure that there really will be widespread support for a
feature or rule and that all viewpoints have been considered.  The only
issue on which the Forth94 TC failed to get consensus was locals: we
struggled with them for years, and ended up deadlocked on the issue of
the order in which things were removed from the stack.  By one vote we
chose to follow the only existing widespread usage (MacForth) and folks
have been unhappy ever since.

No proposal that doesn't have really broad consensus should be adopted.

Cheers,
Elizabeth

--
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310-491-3356
5155 W. Rosecrans Ave. #1018  Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================


 
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 Jul 24 2007, 6:34 pm
Newsgroups: comp.lang.forth
From: Alex McDonald <b...@rivadpm.com>
Date: Tue, 24 Jul 2007 15:34:08 -0700
Local: Tues, Jul 24 2007 6:34 pm
Subject: Re: RfD: Enhanced local variable syntax
On 24 Jul, 18:57, Elizabeth D Rather <erather...@forth.com> wrote:

It's nice you think that my opinion has some standing. But I'm not the
entire Win32Forth community, and I don't stand by proxy for them; it's
just my personal opinion. I'll readily defer to those with greater
knowledge and understanding of the issues.

--
Regards
Alex McDonald


 
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.
Messages 1 - 25 of 49   Newer >
« Back to Discussions « Newer topic     Older topic »