# Re: [stack] small additions to interp.c

## John Cowan — 2001-05-17 15:50:32

    Manfred von Thun wrote:

     > The first new operator is "rotate" for interchanging the

    > first and third element of the stack. The other new operators

    > are variants of the (now 6) ordinary stack shuffling operators.

    > For  X = (pop,dup,swap,rollup,rolldown,rotate), a variant

    > is introduced called "Xd", with the "d" for "dipped".

     Integrating these will be trivial.  However, I do not have C

    code for rollup, rolldown yet!  Nor is it on the Web site.

    --

    There is / one art             || John Cowan <jcowan@...>

    no more / no less              || http://www.reutershealth.com

    to do / all things             || http://www.ccil.org/~cowan

    with art- / lessness           \\ -- Piet Hein

## Manfred von Thun — 2001-05-22 01:02:18

    On Thu, 17 May 2001, John Cowan wrote:

     > Manfred von Thun wrote:

    >

    > > The first new operator is "rotate" for interchanging the

    > > first and third element of the stack. The other new operators

    > > are variants of the (now 6) ordinary stack shuffling operators.

    > > For  X = (pop,dup,swap,rollup,rolldown,rotate), a variant

    > > is introduced called "Xd", with the "d" for "dipped".

    >

    >

    > Integrating these will be trivial.  However, I do not have C

    > code for rollup, rolldown yet!  Nor is it on the Web site.

     Oops. So sorry. Here it is:

    --- the three stack shuffling operators affecting the top three

    --- items on the stack. Insert this just after "swap"

    PRIVATE void rollup_()

    {

        THREEPARAMS("rollup");

        SAVESTACK;

        TERNARY(SAVED1->op,SAVED1->u.num);

        NULLARY(SAVED3->op,SAVED3->u.num);

        NULLARY(SAVED2->op,SAVED2->u.num);

        POP(dump);

    }

    PRIVATE void rolldown_()

    {

        THREEPARAMS("rolldown");

        SAVESTACK;

        TERNARY(SAVED2->op,SAVED2->u.num);

        NULLARY(SAVED1->op,SAVED1->u.num);

        NULLARY(SAVED3->op,SAVED3->u.num);

        POP(dump);

    }

    PRIVATE void rotate_()

    {

        THREEPARAMS("rotate");

        SAVESTACK;

        TERNARY(SAVED1->op,SAVED1->u.num);

        NULLARY(SAVED2->op,SAVED2->u.num);

        NULLARY(SAVED3->op,SAVED3->u.num);

        POP(dump);

    }

    --- The online manual for the above three operators.

    --- Insert this just after the online entries for "swap".

    {"rollup",		rollup_,	"X Y Z  ->  Z X Y",

    "Moves X and Y up, moves Z down"},

    {"rolldown",		rolldown_,	"X Y Z  ->  Y Z X",

    "Moves Y and Z down, moves X up"},

    {"rotate",		rotate_,	"X Y Z  ->  Z Y X",

    "Interchanges X and Z"},

    --- You already have the additions for the "dipped" versions.

    Very sorry about wasting your time.

      - Manfred

## John Cowan — 2001-05-22 02:57:42

    Manfred von Thun scripsit:

     > On Thu, 17 May 2001, John Cowan wrote:

    >

    > > Manfred von Thun wrote:

    > >

    > > > The first new operator is "rotate" for interchanging the

    > > > first and third element of the stack. The other new operators

    > > > are variants of the (now 6) ordinary stack shuffling operators.

    > > > For  X = (pop,dup,swap,rollup,rolldown,rotate), a variant

    > > > is introduced called "Xd", with the "d" for "dipped".

    > >

    > > Integrating these will be trivial.  However, I do not have C

    > > code for rollup, rolldown yet!  Nor is it on the Web site.

    >

    > Oops. So sorry. Here it is:

     Integrated.  The new version is available at the usual place:

    http://www.ccil.org/~cowan/joy.tar.gz .

    --

    John Cowan                                   cowan@...

    One art/there is/no less/no more/All things/to do/with sparks/galore

    	--Douglas Hofstadter

## Manfred von Thun — 2001-05-22 04:30:04

    On Mon, 21 May 2001, John Cowan wrote:

     > Manfred von Thun scripsit:

    > > Oops. So sorry. Here it is:

    >

    > Integrated.  The new version is available at the usual place:

    > http://www.ccil.org/~cowan/joy.tar.gz .

     (Tuesday, about an hour after I received your message above)

    I think you left out  interp.c  in the tar-file.

    I did:

      gunzip joy.tar.gz                  no complaints

      tar -xf joy.tar                    no complaints

      make                               the usual very long messages

                                         wizzing by, and finally:

                 gcc: interp.o No such file or directory

                 make[1]: *** [joy] Error 1

                 make[1]: Leaving directory `home/staff/manfred/cowan'

                 make: ***[all] Error 2

      ls                                 no interp.c  no interp.o

      more joy.tar

                                         looking for interp.c  or for

                                         stuff inside that - no luck

    Just an oversight, I suppose.

      - Manfred

## Manfred von Thun — 2001-05-22 07:11:02

    On Mon, 21 May 2001, John Cowan wrote:

     >

    > Integrated.  The new version is available at the usual place:

    > http://www.ccil.org/~cowan/joy.tar.gz .

    >

     I know you already have implemented "fold", but I have not seen

    it yet. Before you fix the tar-file with te missing  interp.c,

    would you please consider the following implemenation of "fold".

    It really mimicks the definition

       fold  ==  [swap] dip step

    that I had given earlier. Now we have swapd, we might as well use it.

    This can go anywhere after all the DIPPED definitions, perhaps

    just after step.

    PRIVATE void fold_()

    {

        swapd_(); step_();

    }

    The online manual entry, also just after the "step" entry:

    {"fold",			fold_,		"A  V0  BIN  ->  V1",

    "Starting with value V0, sequentially puts members of aggregate A onto stack andcombines with binary operator BIN to finally prodice value V1"},

    I hope you are not getting tired of all this, but that is the

    end of my wishlist that I foreshadowed a while back.

    Thanks for all your work.

      - Manfred

## John Cowan — 2001-05-22 11:04:41

    Manfred von Thun scripsit:

     > I know you already have implemented "fold", but I have not seen

    > it yet. Before you fix the tar-file with the missing interp.c,

    > would you please consider the following implemenation of "fold".

    > It really mimicks the definition

    >    fold  ==  [swap] dip step

    > that I had given earlier. Now we have swapd, we might as well use it.

     Done.

     > I hope you are not getting tired of all this,

     Not at all!  Working on Joy continues to be a joy.

    --

    John Cowan                                   cowan@...

    One art/there is/no less/no more/All things/to do/with sparks/galore

    	--Douglas Hofstadter

## Manfred von Thun — 2001-05-23 07:56:04

    On Tue, 22 May 2001, John Cowan wrote:

     > Manfred von Thun scripsit:

    > > I hope you are not getting tired of all this,

    > Not at all!  Working on Joy continues to be a joy.

    > --

    > John Cowan                                   cowan@...

     I unpacked your latest version of  joy.tar.gz

    Congratulations. I tried:

        1. Sun   under Linux,    "make" got joy with BDW  seems A1 OK

        2. Alpha under DEC-unix, "make" got joy with BDW  seems A1 OK

        3. Alpha under DEC VMS,  I only tried manual CC for the joy files,

                                      got joy with NOBDW  seems A1 OK

           I'll have to try to understand the three makefiles that you

           supplied to translate into VMS. That will be hard for me.

           (Incidentally, your joy1.exe is now 36% bigger than my joy0.exe)

    So, Joymaster, well done, and thank you very very much.

    I hope that others in the group will unpack your latest version

    to see how it works on their machines.

    I shall draft a notice about your joy1 to go to the comp.lang.functional

    newsgroup. I'll send it to concatenative first to hear comments

    from the group and especially from you.

      - Manfred

## John Cowan — 2001-05-23 11:22:01

    Manfred von Thun scripsit:

     >     3. Alpha under DEC VMS,  I only tried manual CC for the joy files,

    >                                   got joy with NOBDW  seems A1 OK

    >        I'll have to try to understand the three makefiles that you

    >        supplied to translate into VMS. That will be hard for me.

     The general logic is:

    makefile does a "make test" in the gc directory.  If that works, it

    creates gc.succ as a sentinel so it doesn't have to do it again,

    and invokes make.gc to compile the joy files with GC_BDW defined

    and the gc library linked in.  If it doesn't work, then it creates

    gc.fail as a sentinel, and invokes make.nogc to compile the

    joy files with GC_BDW not defined.  There is probably a cleverer

    way to do this, but I am not a "make" maven.

    Anyway, the gc library is not supported under VMS, so a sensible

    VMS build procedure would just ignore the gc library and compile

    the joy files directly, as you did.  If and when there is

    VMS support, there will presumably be a VMS build procedure

    for gc as well.  The gc/README.alpha file implies that VMS support

    would not be trivial.

     >        (Incidentally, your joy1.exe is now 36% bigger than my joy0.exe)

     Sounds about right.  It will require more memory at run time, too, because

    Nodes are bigger.

     > So, Joymaster, well done, and thank you very very much.

    > I hope that others in the group will unpack your latest version

    > to see how it works on their machines.

     Yes, please!

     > I shall draft a notice about your joy1 to go to the comp.lang.functional

    > newsgroup. I'll send it to concatenative first to hear comments

    > from the group and especially from you.

     Great.

    --

    John Cowan                                   cowan@...

    One art/there is/no less/no more/All things/to do/with sparks/galore

    	--Douglas Hofstadter

## Manfred von Thun — 2001-05-24 06:28:00

    On Wed, 23 May 2001, John Cowan wrote:

     > Manfred von Thun scripsit:

     [Stuff about gcc under VMS deleted, thanks John]

     > > I shall draft a notice about your joy1 to go to the comp.lang.functional

    > > newsgroup. I'll send it to concatenative first to hear comments

    > > from the group and especially from you.

    >

    > Great.

     Here is my draft:

    newsgroup:  comp.lang.functional

      subject:  ANNOUNCE: enhancements to Joy

    I am please to announce John Cowan's substantial enhancements to

    the prototype C-implemenation of Joy, a purely functional language.

    John's additions are:

      1. Floats (real numbers) as a new datatype, together with

         numerous new functions over floats.

      2. Files as a datatype, together with some common functions

         for manipulation files and IO.

      3. Some new string functions. Also, for unix?/gcc? only, an option

         to include garbage collection for strings.

      4. Some bugs in my prototype have been fixed. Portability

         has been further increased.

    It is intended that the new implementation becomes known as Joy1,

    and that my earlier prototype, now Joy0, should gradually fade away.

    I am enormously grateful to John for his work.

      - Manfred von Thun

    The new Joy1 is available

       1. directly from John Cowan:

            http://www.ccil.org/~cowan/joy.tar.gz

    or 2. from the Joy site:

            http://www.latrobe.edu.au/www/philosophy/phimvt/??? (not yet!)

          Note: The main page of the Joy site is

            http://www.latrobe.edu.au/www/philosophy/phimvt/j00syn.html

    From the main page:

    The language Joy is a purely functional programming language.

    Whereas all other functional programming languages are based

    on the application of functions to arguments, Joy is based on

    the composition of functions.  All such functions take a

    stack as argument and produce a stack as value. Consequently

    much of Joy looks like ordinary postfix notation.  However,

    in Joy a function can consume any number of parameters from

    the stack and leave any number of results on the stack. The

    concatenation of appropriate programs denotes the composition

    of the functions which the programs denote.  One of the

    datatypes of Joy is that of quoted programs, of which lists

    are a special case.  Some functions expect quoted programs

    on top of the stack and execute them in many different ways,

    effectively by dequoting.  So, where other functional languages

    use abstraction and application, Joy uses quotation and

    combinators -- functions which perform dequotation.  As a

    result, there are no named formal parameters, no substitution

    of actual for formal parameters, and no environment of

    name-value pairs.  Combinators in Joy behave much like

    functionals or higher order functions in other languages,

    they minimise the need for recursive and non-recursive

    definitions.  Joy has a rich but simple algebra, and its

    programs are easily manipulated by hand and by other programs.

## John Cowan — 2001-05-24 14:29:05

    Manfred von Thun wrote:

     > Here is my draft:

     Here's my slightly edited version.

    Newsgroups:  comp.lang.functional

    Subject:  ANNOUNCE: enhancements to Joy

    I am pleased to announce John Cowan's substantial enhancements to

    the prototype C implementation of Joy, a purely functional language.

    John's additions are:

      1. Floats (real numbers) as a new datatype, together with

         numerous new functions over floats.

      2. Files as a datatype, together with some common functions

         for manipulating files and doing I/O.

      3. Some new string functions. Also, on most platforms, an option

         to include garbage collection for strings.

      4. Some bugs in my prototype have been fixed. Portability

         has been further increased.  Joy1 will still compile and run

          with any strictly conforming ISO C compiler.

    The currently supported platforms for the general garbage collector

    include Unix/Linux/*BSD on i386/Alpha/SPARC/SGI/HP, OS/2,

    Win32 native/Cygwin/DJGPP, and perhaps Macintosh.  One system

    known *not* to work is OpenVMS.  Joy1 has not yet been built on all

    these systems.

    It is intended that the new implementation become known as Joy1,

    and that my earlier prototype, now Joy0, should gradually fade away.

    I am enormously grateful to John for his work.

      - Manfred von Thun

    The new Joy1 is available:

       1. directly from John Cowan:

            http://www.ccil.org/~cowan/joy.tar.gz

    or 2. from the Joy site:

            http://www.latrobe.edu.au/www/philosophy/phimvt/??? (not yet!)

    Note: The main page of the Joy site is

            http://www.latrobe.edu.au/www/philosophy/phimvt/j00syn.html

    --

    There is / one art             || John Cowan <jcowan@...>

    no more / no less              || http://www.reutershealth.com

    to do / all things             || http://www.ccil.org/~cowan

    with art- / lessness           \\ -- Piet Hein

## Manfred von Thun — 2001-05-29 04:07:36

    On Thu, 24 May 2001, John Cowan wrote:

     >

    > Here's my slightly edited version.

    >

     Thanks, John. I am currently snowed under with end-of-semester marking,

    so it will probably be next week till I really get aroung to it.

      - Manfred

## Manfred von Thun — 2001-05-31 09:19:39

    On Tue, 29 May 2001, Manfred von Thun wrote:

     >

    > On Thu, 24 May 2001, John Cowan wrote:

    > >

    > > Here's my slightly edited version.

    > >

    > Thanks, John. I am currently snowed under with end-of-semester marking,

    > so it will probably be next week till I really get aroung to it.

     I have now made the changes to the main page of Joy -

      http://www.latrobe.edu,au/www/philos/phimvt/j00syn.html

    (except that the link to the joy.tar.gz currently still points

     to John's site. I'll keep a local copy when advised to.)

    Please have a look, let me know what you think.

    I will wait with the announcement to comp.lang.functional

    and I think I should also send one to comp.lang.misc

    But I'll wait for a week or so, in case there are any

    changes I should make first to the Joy web page.

      - Manfred