Google Groups Home
Help | Sign in
RfD - FVALUE
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
  21 messages - Collapse all
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
Marcel Hendrix  
View profile
 More options Aug 25 2006, 4:25 pm
Newsgroups: comp.lang.forth
From: m...@iae.nl (Marcel Hendrix)
Date: Fri, 25 Aug 2006 20:25:03 GMT
Local: Fri, Aug 25 2006 4:25 pm
Subject: RfD - FVALUE
RfD - FVALUE
Marcel Hendrix, August 25, 2006

* First draft *

Rationale
=========
Problem
-------
The word VALUE was considered useful enough to be included in ANS94.
A search through 4827 source files shows 532 occurences of VARIABLE
versus 4241 uses of VALUE. It would be obviously useful to have a
variant of VALUE that works for floating-point values.

The main idea behind FVALUE is that fetching a variable is more
frequent than changing it. Therefore both readibility of source code
and efficiency of execution can be achieved by making 'F@' the default
action of FVALUE.

Current practice
----------------
The proposed form of FVALUE has been in use in tForth, iForth, and their
predecessors since 1985. FVALUE (with TO) is also in use for Mops and
MacForth. The systems mentioned define more TO-like words that work on
values, e.g. +TO -TO CLEAR, with obvious meanings.

This proposal does not propose to standardize on these extensions.

Solution
--------
Although many people have objected to parsing words, parsing
permits the host system the most flexibility in implementation
and is thus the preferred solution (see also TO).

The syntax is:
  123e0 FVALUE fdata
to define <fdata> as a floating-point value initialized to <123e0>.

To access the value of fdata:
   fdata 2e0 F+ F. <cr> 125.000000  ok

To change fdata:
   fdata 2e0 F+ TO fdata  fdata F. <cr> 125.000000  ok

Proposal
========
12.6.1.xxxx FVALUE                     "f-value"                                  FLOATING
                  ( F: x -- ) ( "<spaces>name" -- )
                  Skip leading space delimiters.  Parse name delimited by a space.  Create
                  a definition for name with the execution semantics defined below, with
                  an initial value equal to x.
                  name is referred to as an "f-value".
  name Execution: ( F: -- x )
                  Place x on the FP stack.  The value of x is that given when name was
                  created, until the phrase x TO name is executed, causing a new value of
                  x to be associated with name.
        See: 3.4.1 Parsing.

6.2.2295   TO                                                                     CORE EXT
  Interpretation: ( x "<spaces>name" -- ) or ( F: x -- ) ( "<spaces>name" -- )
                  Skip leading spaces and parse name delimited by a space.  Store x in
                  name.  An ambiguous condition exists if name was not defined by VALUE or FVALUE.
     Compilation: ( "<spaces>name" -- )
                  Skip leading spaces and parse name delimited by a space.  Append the
                  run-time semantics given below to the current definition.  An ambiguous
                  condition exists if name was not defined by VALUE or FVALUE.
        Run-time: ( x -- ) or ( F: x -- )
                  Store x in name.
        Note: An ambiguous condition exists if either POSTPONE or [COMPILE] is applied to TO.
        See: 6.2.2405 VALUE, 12.6.1.xxxx FVALUE, 13.6.1.2295 TO.

13.6.1.2295   TO                                                                     LOCAL
                  Extend the semantics of 6.2.2295 TO to be:
  Interpretation: ( x "<spaces>name" -- ) or ( F: x -- ) ( "<spaces>name" -- )
                  Skip leading spaces and parse name delimited by a space.  Store x in
                  name.  An ambiguous condition exists if name was not defined by VALUE or FVALUE.
     Compilation: ( "<spaces>name" -- )
                  Skip leading spaces and parse name delimited by a space.  Append the
                  run-time semantics given below to the current definition.  An ambiguous
                  condition exists if name was not defined by either VALUE, FVALUE or (LOCAL).
        Run-time: ( x -- ) or ( F: x -- )
                  Store x in name.
            Note:
An ambiguous condition exists if either POSTPONE or [COMPILE] is applied to TO.
             See: 3.4.1 Parsing, 6.2.2295 TO, 6.2.2405 VALUE, 12.6.1.xxxx FVALUE, 13.6.1.0086 (LOCAL).

Labelling
=========
TBD

Reference Implementation
========================
The implementation of FVALUE requires carnal knowledge of the host
implementation, which is the main reason why it should be standardized.

The implementation below disregards the issue that TO should also
work for integer VALUEs and locals.

: FVALUE  CREATE F, ( F: r -- )  DOES> F@ ; ( F: -- r )

: TO    ( F: r -- ) ( "<spaces>name" -- )
        ' >BODY
        STATE @ IF  POSTPONE LITERAL  POSTPONE F!
              ELSE  F!  
              THEN ; IMMEDIATE

Test Cases
==========
  123e FVALUE fdata
    2   VALUE idata

: foo ( -- )
    idata LOCALS| ldata |
    ldata .  idata 2* TO ldata  ldata .
    idata 1 D>F TO fdata  fdata F.
    fdata 33e F+ F>D D>S TO idata  idata .
    ldata idata + fdata F>D D>S + . ;

foo <cr> 2 4 4.294967e9 35 41  ok


    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 25 2006, 4:39 pm
Newsgroups: comp.lang.forth
From: m...@iae.nl (Marcel Hendrix)
Date: Fri, 25 Aug 2006 20:39:09 GMT
Local: Fri, Aug 25 2006 4:39 pm
Subject: RfD - FVALUE
RfD - FVALUE
Marcel Hendrix, August 25, 2006

* First draft *
* First spell-checked draft *

Rationale
=========
Problem
-------
The word VALUE was considered useful enough to be included in ANS94.
A search through 4827 source files shows 532 occurrences of VARIABLE
versus 4241 uses of VALUE. It would be obviously useful to have a
variant of VALUE that works for floating-point values.

The main idea behind FVALUE is that fetching a variable is more
frequent than changing it. Therefore both readability of source code
and efficiency of execution can be achieved by making 'F@' the default
action of FVALUE.

Current practice
----------------
The proposed form of FVALUE has been in use in tForth, iForth, and their
predecessors since 1985. FVALUE (with TO) is also in use for Mops and
MacForth. The systems mentioned define more TO-like words that work on
values, e.g. +TO -TO CLEAR, with obvious meanings.

This proposal does not propose to standardize on these extensions.

Solution
--------
Although many people have objected to parsing words, parsing
permits the host system the most flexibility in implementation
and is thus the preferred solution (see also TO).

The syntax is:
  123e0 FVALUE fdata
to define <fdata> as a floating-point value initialized to <123e0>.

To access the value of fdata:
   fdata 2e0 F+ F. <cr> 125.000000  ok

To change fdata:
   fdata 2e0 F+ TO fdata  fdata F. <cr> 125.000000  ok

Proposal
========
12.6.1.xxxx FVALUE                     "f-value"                                  FLOATING
                  ( F: x -- ) ( "<spaces>name" -- )
                  Skip leading space delimiters.  Parse name delimited by a space.  Create
                  a definition for name with the execution semantics defined below, with
                  an initial value equal to x.
                  name is referred to as an "f-value".
  name Execution: ( F: -- x )
                  Place x on the FP stack.  The value of x is that given when name was
                  created, until the phrase x TO name is executed, causing a new value of
                  x to be associated with name.
        See: 3.4.1 Parsing.

6.2.2295   TO                                                                     CORE EXT
  Interpretation: ( x "<spaces>name" -- ) or ( F: x -- ) ( "<spaces>name" -- )
                  Skip leading spaces and parse name delimited by a space.  Store x in
                  name.  An ambiguous condition exists if name was not defined by VALUE or FVALUE.
     Compilation: ( "<spaces>name" -- )
                  Skip leading spaces and parse name delimited by a space.  Append the
                  run-time semantics given below to the current definition.  An ambiguous
                  condition exists if name was not defined by VALUE or FVALUE.
        Run-time: ( x -- ) or ( F: x -- )
                  Store x in name.
        Note: An ambiguous condition exists if either POSTPONE or [COMPILE] is applied to TO.
        See: 6.2.2405 VALUE, 12.6.1.xxxx FVALUE, 13.6.1.2295 TO.

13.6.1.2295   TO                                                                   LOCAL
                  Extend the semantics of 6.2.2295 TO to be:
  Interpretation: ( x "<spaces>name" -- ) or ( F: x -- ) ( "<spaces>name" -- )
                  Skip leading spaces and parse name delimited by a space.  Store x in
                  name.  An ambiguous condition exists if name was not defined by VALUE or FVALUE.
     Compilation: ( "<spaces>name" -- )
                  Skip leading spaces and parse name delimited by a space.  Append the
                  run-time semantics given below to the current definition.  An ambiguous
                  condition exists if name was not defined by either VALUE, FVALUE or (LOCAL).
        Run-time: ( x -- ) or ( F: x -- )
                  Store x in name.
            Note:
An ambiguous condition exists if either POSTPONE or [COMPILE] is applied to TO.
             See: 3.4.1 Parsing, 6.2.2295 TO, 6.2.2405 VALUE, 12.6.1.xxxx FVALUE, 13.6.1.0086 (LOCAL).

Labeling
=========
TBD

Reference Implementation
========================
The implementation of FVALUE requires carnal knowledge of the host
implementation, which is the main reason why it should be standardized.

The implementation below disregards the issue that TO should also
work for integer VALUEs and locals.

: FVALUE  CREATE F, ( F: r -- )  DOES> F@ ; ( F: -- r )

: TO    ( F: r -- ) ( "<spaces>name" -- )
        ' >BODY
        STATE @ IF  POSTPONE LITERAL  POSTPONE F!
              ELSE  F!  
              THEN ; IMMEDIATE

Test Cases
==========
  123e FVALUE fdata
    2   VALUE idata

: foo ( -- )
    idata LOCALS| ldata |
    ldata .  idata 2* TO ldata  ldata .
    idata 1 D>F TO fdata  fdata F.
    fdata 33e F+ F>D D>S TO idata  idata .
    ldata idata + fdata F>D D>S + . ;

foo <cr> 2 4 4.294967e9 35 41  ok


    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.
Anton Ertl  
View profile
 More options Aug 25 2006, 4:01 pm
Newsgroups: comp.lang.forth
From: an...@mips.complang.tuwien.ac.at (Anton Ertl)
Date: Fri, 25 Aug 2006 20:01:58 GMT
Local: Fri, Aug 25 2006 4:01 pm
Subject: Re: RfD - FVALUE

m...@iae.nl (Marcel Hendrix) writes:
>RfD - FVALUE
>Marcel Hendrix, August 25, 2006

>* First draft *
>* First spell-checked draft *

How about a draft that can be read even on 80-char-wide terminals?

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


    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 25 2006, 4:28 pm
Newsgroups: comp.lang.forth
From: w...@megawolf.com (ward mcfarland)
Date: Fri, 25 Aug 2006 16:28:58 -0400
Local: Fri, Aug 25 2006 4:28 pm
Subject: Re: RfD - FVALUE

Marcel Hendrix <m...@iae.nl> wrote:
> RfD - FVALUE

I have no trouble supporting this, since as you mentioned, MacForth
supports FLOCAL and  TO  +TO both work fine with FLOCAL's.

 -- w


    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 25 2006, 5:23 pm
Newsgroups: comp.lang.forth
From: "Julian V. Noble" <j...@virginia.edu>
Date: Fri, 25 Aug 2006 17:23:00 -0400
Subject: Re: RfD - FVALUE

What is wrong with FTO vs TO for FVALUEs? Why do you want
to make TO smart enough to tell the difference between an
integer and a floating point VALUE ? If you're going to do
that why not make VALUE smart enough to tell the difference?

--
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.
werty  
View profile
 More options Aug 25 2006, 5:46 pm
Newsgroups: comp.lang.forth
From: "werty" <we...@swissinfo.org>
Date: 25 Aug 2006 14:46:07 -0700
Local: Fri, Aug 25 2006 5:46 pm
Subject: Re: RfD - FVALUE

 I dont see any value in this discussion of an ambiguios cmd called
Value ha ha hahhahhha

 Certainly you can figure a more intuitive cmd than that !!

  What kind of Value ? Where used ?!!

 You better switch from the old obsolete Forth to NewForth ....


    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.
Doug Hoffman  
View profile
 More options Aug 25 2006, 8:56 pm
Newsgroups: comp.lang.forth
From: "Doug Hoffman" <dhoff...@talkamerica.net>
Date: 25 Aug 2006 17:56:25 -0700
Local: Fri, Aug 25 2006 8:56 pm
Subject: Re: RfD - FVALUE

Marcel Hendrix wrote:
> RfD - FVALUE
> Marcel Hendrix, August 25, 2006

> * First draft *

[delete]

Bravo Marcel!  My enthusiasm for Forth is getting re-energized with
(even if overdue) standards proposals such as this and those by Stephen
Pelc.

Regards,

-Doug


    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.
Doug Hoffman  
View profile
 More options Aug 25 2006, 9:14 pm
Newsgroups: comp.lang.forth
From: "Doug Hoffman" <dhoff...@talkamerica.net>
Date: 25 Aug 2006 18:14:45 -0700
Local: Fri, Aug 25 2006 9:14 pm
Subject: Re: RfD - FVALUE
Hi Julian,

You wrote:
> What is wrong with FTO vs TO for FVALUEs? Why do you want
> to make TO smart enough to tell the difference between an
> integer and a floating point VALUE ?

I think the idea here is to help reduce the "name explosion" problem.

> If you're going to do that why not make VALUE smart enough
> to tell the difference?

Because one can quickly check the "type" of the (F)VALUE, integer or
float, simply by checking its declaration.  Otherwise things could get
pretty confusing.  I think I understand your point.  But a balance must
be struck between polymorphic words and type declaration.  Also, I
believe most existing code will not be broken by sticking to Marcel's
proposal.

You could always use SYNONYM for your own code if you prefer FTO.  :-)

Regards,

-Doug


    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 26 2006, 3:56 am
Newsgroups: comp.lang.forth
From: m...@iae.nl (Marcel Hendrix)
Date: Sat, 26 Aug 2006 07:56:27 GMT
Local: Sat, Aug 26 2006 3:56 am
Subject: Re: RfD - FVALUE
"Julian V. Noble" <j...@virginia.edu> writes Re: RfD - FVALUE

> Marcel Hendrix wrote:
>> RfD - FVALUE
> What is wrong with FTO vs TO for FVALUEs?

It has no history. I think FTO was implemented by Jos Ven for
Win32F because he wanted to quickly port some iForth stuff and
didn't find the internals of TO quickly enough.

Defining FTO would be against Paul Bartholdi's initial vision.
(Check the on-line FD annals for the TO concept).

Programmers really wanting FTO can use a SYNONYM, as others
have suggested.

>                                           Why do you want
> to make TO smart enough to tell the difference between an
> integer and a floating point VALUE ?

In the context of standardization it only matters that I have
done so, and a sizeable number of other implementations found
it a good idea too.

>                                      If you're going to do
> that why not make VALUE smart enough to tell the difference?

The difference in what? Do you mean:

    55 VALUE a
66e-12 VALUE b
     0 VALUE c

a b + TO c

As you can see, a smart VALUE wouldn't help.
But I don't think you are serious :-)

BTW: I see that VFX 3.9 also supports FVALUE, with TO.

-marcel


    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.