Unexpected abilities (and disabilities) of Ftran201 
Author Message
 Unexpected abilities (and disabilities) of Ftran201

Dear Forth Community,

Disability:

In order to avoid having to use .NAME, which is apparently
impossible to define in a portable ANS-compatible fashion,
I implemented the fp and complex function libraries using
big CASE statements, as Neil Bawd advised. This leads to
the following problem (which isn't much of a problem): if
you want to use the function FCOSH, you can call it FCOSH
or COSH--the leading F is added if it isn't there. However,
if you define, say,

        FWITHIN ( f: x a b -- true if a<=x<=b)

you had better say FWITHIN and not WITHIN. The parser adds
the leading F, but FIND provides only the xt if a word is found
(not the keys to the name string or anything useful like that);
so lacking a generic .NAME one can go no further except by adding
a string to the function library.

However, compensating that is the possibility of doing
things that fortran never dreamed of. For example, define
the function

        : LessThan   F<  ;

and compute the stopping criterion

        f" LessThan( ABS( x-xprime), epsilon )"

to compile the code


(FABS is in the library!). But you can do more:

        (f: |m| --) f" a = LessThan( zdup( ABS( mat{{ Iperm Col }} ) ) )"


which performs a test and stores a result in one line!

The possibilities of concatenating functions to produce
code as terse and unreadable as Perl or Awk are apparently
unlimited! But seriously, such locutions might be useful
as well as possible, so I offer them for what they are worth.

--
Julian V. Noble
Professor of Physics



Mon, 15 Mar 2004 10:06:34 GMT  
 Unexpected abilities (and disabilities) of Ftran201
Quote:

>  ...

>         FWITHIN ( f: x a b -- true if a<=x<=b)

Great sadness. WITHIN ( x a b -- true if a<=x<b ) is the standard,
where x, a, and b may be signed or unsigned; never mind why, history
wins. You want me to remember two schemas. Can you tell me why?

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



Mon, 15 Mar 2004 10:40:30 GMT  
 Unexpected abilities (and disabilities) of Ftran201


Quote:

> >  ...

> >         FWITHIN ( f: x a b -- true if a<=x<=b)

> Great sadness. WITHIN ( x a b -- true if a<=x<b ) is the standard,
> where x, a, and b may be signed or unsigned; never mind why, history
> wins. You want me to remember two schemas. Can you tell me why?

    The great sadness is that the standard WITHIN is broken.  Just throw it
away and do it right (I did).

--

-GJC

-Abolish Public Schools.



Mon, 15 Mar 2004 13:25:55 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:


>>  ...

>>         FWITHIN ( f: x a b -- true if a<=x<=b)

>Great sadness. WITHIN ( x a b -- true if a<=x<b ) is the standard,
>where x, a, and b may be signed or unsigned; never mind why, history
>wins. You want me to remember two schemas. Can you tell me why?

Isn't that ( x a b -- a<=x<=b? ) BETWEEN in someone's toolkit?  If so,
use that name.


Mon, 15 Mar 2004 15:08:36 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:


> >  ...

> >         FWITHIN ( f: x a b -- true if a<=x<=b)

> Great sadness. WITHIN ( x a b -- true if a<=x<b ) is the standard,
> where x, a, and b may be signed or unsigned; never mind why, history
> wins. You want me to remember two schemas. Can you tell me why?

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

Well, if you wanted to add an extra line to the function "library"
in ftran201.f,

: func_lib  ( xt -- c-adr)
    CASE    [']  FABS   OF   C"  FABS "     ENDOF
            [']  FACOS  OF   C"  FACOS "    ENDOF
            [']  FACOSH OF   C"  FACOSH "   ENDOF
            [']  FASIN  OF   C"  FASIN "    ENDOF
            [']  FASINH OF   C"  FASINH "   ENDOF
            [']  FATAN  OF   C"  FATAN "    ENDOF
            [']  FATAN2 OF   C"  FATAN2 "   ENDOF
            [']  FATANH OF   C"  FATANH "   ENDOF
            [']  FCOS   OF   C"  FCOS "     ENDOF
            [']  FCOSH  OF   C"  FCOSH "    ENDOF
            [']  FEXP   OF   C"  FEXP "     ENDOF
            [']  FLN    OF   C"  FLN "      ENDOF
            [']  FMAX   OF   C"  FMAX "     ENDOF
            [']  FMIN   OF   C"  FMIN "     ENDOF
            [']  FSIN   OF   C"  FSIN "     ENDOF
            [']  FSINH  OF   C"  FSINH "    ENDOF
            [']  FTAN   OF   C"  FTAN "     ENDOF
            [']  FSQRT  OF   C"  FSQRT "    ENDOF
            [']  FTANH  OF   C"  FTANH "    ENDOF
    ENDCASE
;

namely,

        ['] FWITHIN  OF  C"  FWITHIN "  ENDOF

then be my guest. But you have to define FWITHIN first
of course. This definition is

        : fwithin    ( f: x a b --) ( -- true if a <= x <= b)
                FROT  FSWAP  FOVER   FMIN  FROT FROT   FMAX   F=  ;

--
Julian V. Noble
Professor of Physics

Galileo's Commandment:

   "Science knows only one commandment: contribute to science."
   -- Bertolt Brecht, "Galileo".



Tue, 16 Mar 2004 00:32:10 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:




> > >  ...

> > >         FWITHIN ( f: x a b -- true if a<=x<=b)

> > Great sadness. WITHIN ( x a b -- true if a<=x<b ) is the standard,
> > where x, a, and b may be signed or unsigned; never mind why, history
> > wins. You want me to remember two schemas. Can you tell me why?

>     The great sadness is that the standard WITHIN is broken.  Just throw it
> away and do it right (I did).

> --

> -GJC

> -Abolish Public Schools.

The Standard WITHIN, broken or unbroken, is beside the point.
It works for integers. I was pointing out that if I had .NAME
or xt>NAME$ or something of that sort available in Standard
Forth--or at least the tools to construct it portably--there
would be no difficulty.

See my answer to Jerry.

--
Julian V. Noble
Professor of Physics

Galileo's Commandment:

   "Science knows only one commandment: contribute to science."
   -- Bertolt Brecht, "Galileo".



Tue, 16 Mar 2004 00:34:39 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:



> >>  ...

> >>         FWITHIN ( f: x a b -- true if a<=x<=b)

> >Great sadness. WITHIN ( x a b -- true if a<=x<b ) is the standard,
> >where x, a, and b may be signed or unsigned; never mind why, history
> >wins. You want me to remember two schemas. Can you tell me why?

> Isn't that ( x a b -- a<=x<=b? ) BETWEEN in someone's toolkit?  If so,
> use that name.

One can use FWITHIN and it will work fine. I was just pointing out
that the way I had to implement the "function library" as a CASE
statement, rather than just using a non-existent Standard tool to
get from an xt to a name string, function names that are not in
the library (word-name func_lib ) will not be treated exactly the
same as those included therein.

--
Julian V. Noble
Professor of Physics

Galileo's Commandment:

   "Science knows only one commandment: contribute to science."
   -- Bertolt Brecht, "Galileo".



Tue, 16 Mar 2004 00:39:08 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:
> However, compensating that is the possibility of doing
> things that Fortran never dreamed of. For example, define
> the function
>        : LessThan   F<  ;

[..]

Quote:
>       (f: |m| --) f" a = LessThan( zdup( ABS( mat{{ Iperm Col }} ) ) )"

> which performs a test and stores a result in one line!

Let's be glad that FORTRAN never would do this: LessThan delivers an
integer result and F! is inappropriate for storing in whatever a is :-)

Same problem with the type of mat{{ elements, they could be integers or

There is an error in complex.f :

[undefined] 1/f       [IF]  : 1/f   F1.0  FSWAP  F/ ; [THEN]
[undefined] f^2       [IF]  : f^2   FDUP  F*  ;
[undefined] fpi       [IF]  3.1415926535897932385E0  FCONSTANT  fpi  [THEN]

should be:

[undefined] 1/f       [IF]  : 1/f   F1.0  FSWAP  F/ ; [THEN]
[undefined] f^2       [IF]  : f^2   FDUP  F*  ;       [THEN]
[undefined] fpi       [IF]  3.1415926535897932385E0  FCONSTANT  fpi  [THEN]

Remarks:
  Comment out the [UNDEFINED] definition in ftran201.f when your system
  already has that word.

  Neither complex.f nor arrays.f is needed, ftran201.f will work when
  the FSL's fsl_util.xxx and complex.xxx are loaded first.

-marcel



Tue, 16 Mar 2004 02:31:25 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:




> > >  ...

> > >         FWITHIN ( f: x a b -- true if a<=x<=b)

> > Great sadness. WITHIN ( x a b -- true if a<=x<b ) is the standard,
> > where x, a, and b may be signed or unsigned; never mind why, history
> > wins. You want me to remember two schemas. Can you tell me why?

>     The great sadness is that the standard WITHIN is broken.  Just throw it
> away and do it right (I did).

> --

> -GJC

> -Abolish Public Schools.

Broken or not -- we've been through this before -- the name has a
traditional meaning. If you want to change the way WITHIN works,
change the name. BETWEEN has been used; I like it. This community
doesn't need any more of "What exactly does this version of
<fill-in-the-name> do?" "Which WITHIN is this?" is no prettier than
"Which NOT is this?" Do I have your blessing to give my version of
'TO' the name '>' in a public release? If not, why not?

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



Tue, 16 Mar 2004 03:00:02 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:




> > >>  ...

> > >>         FWITHIN ( f: x a b -- true if a<=x<=b)

> > >Great sadness. WITHIN ( x a b -- true if a<=x<b ) is the standard,
> > >where x, a, and b may be signed or unsigned; never mind why, history
> > >wins. You want me to remember two schemas. Can you tell me why?

> > Isn't that ( x a b -- a<=x<=b? ) BETWEEN in someone's toolkit?  If so,
> > use that name.

> One can use FWITHIN and it will work fine.

  ...

Sure it will, but it won't do what you or I expect. It should have
been called FBETWEEN.

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



Tue, 16 Mar 2004 03:02:18 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:



> > >  ...

> > >         FWITHIN ( f: x a b -- true if a<=x<=b)

> > Great sadness. WITHIN ( x a b -- true if a<=x<b ) is the standard,
> > where x, a, and b may be signed or unsigned; never mind why, history
> > wins. You want me to remember two schemas. Can you tell me why?

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

> Well, if you wanted to add an extra line to the function "library"
> in ftran201.f,

> : func_lib  ( xt -- c-adr)
>     CASE    [']  FABS   OF   C"  FABS "     ENDOF
>             [']  FACOS  OF   C"  FACOS "    ENDOF
>             [']  FACOSH OF   C"  FACOSH "   ENDOF
>             [']  FASIN  OF   C"  FASIN "    ENDOF
>             [']  FASINH OF   C"  FASINH "   ENDOF
>             [']  FATAN  OF   C"  FATAN "    ENDOF
>             [']  FATAN2 OF   C"  FATAN2 "   ENDOF
>             [']  FATANH OF   C"  FATANH "   ENDOF
>             [']  FCOS   OF   C"  FCOS "     ENDOF
>             [']  FCOSH  OF   C"  FCOSH "    ENDOF
>             [']  FEXP   OF   C"  FEXP "     ENDOF
>             [']  FLN    OF   C"  FLN "      ENDOF
>             [']  FMAX   OF   C"  FMAX "     ENDOF
>             [']  FMIN   OF   C"  FMIN "     ENDOF
>             [']  FSIN   OF   C"  FSIN "     ENDOF
>             [']  FSINH  OF   C"  FSINH "    ENDOF
>             [']  FTAN   OF   C"  FTAN "     ENDOF
>             [']  FSQRT  OF   C"  FSQRT "    ENDOF
>             [']  FTANH  OF   C"  FTANH "    ENDOF
>     ENDCASE
> ;

> namely,

>         ['] FWITHIN  OF  C"  FWITHIN "  ENDOF

> then be my guest. But you have to define FWITHIN first
> of course. This definition is

>         : fwithin    ( f: x a b --) ( -- true if a <= x <= b)
>                 FROT  FSWAP  FOVER   FMIN  FROT FROT   FMAX   F=  ;

> --
> Julian V. Noble
> Professor of Physics

> Galileo's Commandment:

>    "Science knows only one commandment: contribute to science."
>    -- Bertolt Brecht, "Galileo".

We may be talking past one another. My weltschmerz comes from FWITHIN
as defined not being a floating-point analog of WITHIN. Had it been
called FBETWEEN, my heart would have known joy.

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



Tue, 16 Mar 2004 03:14:47 GMT  
 Unexpected abilities (and disabilities) of Ftran201


Quote:

> Broken or not -- we've been through this before -- the name has a
> traditional meaning. If you want to change the way WITHIN works,
> change the name. BETWEEN has been used; I like it. This community
> doesn't need any more of "What exactly does this version of
> <fill-in-the-name> do?" "Which WITHIN is this?" is no prettier than
> "Which NOT is this?" Do I have your blessing to give my version of
> 'TO' the name '>' in a public release? If not, why not?

    My version of WITHIN predates the standard version so in my context it's
not a change.

--

-GJC

-Abolish Public Schools.



Tue, 16 Mar 2004 03:25:30 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:

> [...]

> Broken or not -- we've been through this before -- the name has a
> traditional meaning. If you want to change the way WITHIN works,
> change the name. BETWEEN has been used; I like it. This community
> doesn't need any more of "What exactly does this version of
> <fill-in-the-name> do?" "Which WITHIN is this?" is no prettier than
> "Which NOT is this?" Do I have your blessing to give my version of
> 'TO' the name '>' in a public release? If not, why not?

Doesn't BETWEEN connote not overlapping the ends?  To me, the
clearer solution would be four words:  [WITHIN]  [WITHIN)
(WITHIN]  (WITHIN)
For floating point, equality at the limits is fuzzy anyway...

-David



Tue, 16 Mar 2004 04:18:03 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:



> > Broken or not -- we've been through this before -- the name has a
> > traditional meaning. If you want to change the way WITHIN works,
> > change the name. BETWEEN has been used; I like it. This community
> > doesn't need any more of "What exactly does this version of
> > <fill-in-the-name> do?" "Which WITHIN is this?" is no prettier than
> > "Which NOT is this?" Do I have your blessing to give my version of
> > 'TO' the name '>' in a public release? If not, why not?

>     My version of WITHIN predates the standard version so in my context it's
> not a change.

> --

> -GJC

> -Abolish Public Schools.

I remember WITHIN from PolyForth. (Chuck had good reason to write it
as he did.*) There were accepted behaviors for Forth words long before
ANSI put its imprimatur on a set of meanings. WITHIN was among them.

Jerry
______________________________
* : WITHIN ( x a b -- a<=x<b ) OVER - >R - R> U< ; is fast,
and works on both signed and unsigned values.
--
Engineering is the art of making what you want from things you can
get.
-----------------------------------------------------------------------



Tue, 16 Mar 2004 05:52:30 GMT  
 Unexpected abilities (and disabilities) of Ftran201

Quote:


> > However, compensating that is the possibility of doing
> > things that Fortran never dreamed of. For example, define
> > the function

> >        : LessThan   F<  ;

> [..]

> >       (f: |m| --) f" a = LessThan( zdup( ABS( mat{{ Iperm Col }} ) ) )"


> > which performs a test and stores a result in one line!

> Let's be glad that FORTRAN never would do this: LessThan delivers an
> integer result and F! is inappropriate for storing in whatever a is :-)

> Same problem with the type of mat{{ elements, they could be integers or

> There is an error in complex.f :

> [undefined] 1/f       [IF]  : 1/f   F1.0  FSWAP  F/ ; [THEN]
> [undefined] f^2       [IF]  : f^2   FDUP  F*  ;
> [undefined] fpi       [IF]  3.1415926535897932385E0  FCONSTANT  fpi  [THEN]

> should be:

> [undefined] 1/f       [IF]  : 1/f   F1.0  FSWAP  F/ ; [THEN]
> [undefined] f^2       [IF]  : f^2   FDUP  F*  ;       [THEN]
> [undefined] fpi       [IF]  3.1415926535897932385E0  FCONSTANT  fpi  [THEN]

        Oops! Thanks, Marcel. That's what beta testers do.

Quote:
> Remarks:
>   Comment out the [UNDEFINED] definition in ftran201.f when your system
>   already has that word.

>   Neither complex.f nor arrays.f is needed, ftran201.f will work when
>   the FSL's fsl_util.xxx and complex.xxx are loaded first.

> -marcel

        Right enough. Of course, since I supply source code,
        users are free to modify anything they want.

--
Julian V. Noble
Professor of Physics

Galileo's Commandment:

   "Science knows only one commandment: contribute to science."
   -- Bertolt Brecht, "Galileo".



Tue, 16 Mar 2004 05:46:49 GMT  
 
 [ 28 post ]  Go to page: [1] [2]

 Relevant Pages 

1. ftran201.f

2. Bug found in ftran201.f

3. LOGO-L> Re: logo for learning disabilities

4. logo for learning disabilities

5. TkCanvas TkcPolygon state disability

6. Disability Awareness VR project

7. American Disabilities Act

8. Assessing Someone's Ability To Learn Smalltalk

9. Enhancing "ls -l" file listing abilities

10. Scrolling w/ "Mark" ability

11. Mark ability in a browse box

12. DOS ability

 

 
Powered by phpBB® Forum Software