# Module/definition syntax

## John Cowan — 2003-02-28 20:02:07

    I think the modern trend (Java, C#) is to mark each individual definition as

    public or private.  In Joy there could be a default: public outside a module,

    private inside a module.  Also, I don't really understand the need for

    DEFINE/LIBRA: since "==" is a reserved token, why can't definitions appear

    mixed with Joy expressions (at the top level only) without the need of a

    special mode-switching word?  This would require only a small amount of

    lookahead, and would IMHO improve the user experience.

    --

    If you have ever wondered if you are in hell,         John Cowan

    it has been said, then you are on a well-traveled     http://www.ccil.org/~cowan

    road of spiritual inquiry.  If you are absolutely   http://www.reutershealth.com

    sure you are in hell, however, then you must be         jcowan@...

    on the Cross Bronx Expressway.          --Alan Feur, NYTimes, 2002-09-20

## Samuel Falvo — 2003-02-28 20:43:48

    > I think the modern trend (Java, C#) is to mark each individual definition as

    > public or private.  In Joy there could be a default: public outside a module,

    > private inside a module.  Also, I don't really understand the need for

    > DEFINE/LIBRA: since "==" is a reserved token, why can't definitions appear

    > mixed with Joy expressions (at the top level only) without the need of a

    > special mode-switching word?  This would require only a small amount of

    > lookahead, and would IMHO improve the user experience.

     Please understand that I'm completely new to Joy, although I'm researching a

    concatenative functional language that supports static typing a la ML or

    Haskell (pretty much for fun, but I'd like it to be practical for me as well).

    Hence why Billy admitted me to this list.  So, I beg your pardon if I seem a

    little ignorant with respect to Joy.

    That being said, I've researched some Joy source code, and I'm relatively

    pleased with what I see.  But DEFINE and LIBRA really stick out like a sore

    thumb to me.  It's not ... concatenative.

    Would it be possible to adopt a syntax like this?

    MyModule ==

      [

       [

        foo == ....

        bar == ....

       ] public-defs [

        baz == ....

        blort == ....

       ] private-defs

      ] module;

    --

    Samuel A. Falvo II

    __________________________________________________

    Do you Yahoo!?

    Yahoo! Tax Center - forms, calculators, tips, more

    http://taxes.yahoo.com/

## phimvt@lurac.latrobe.edu.au — 2003-03-03 02:05:41

    On Fri, 28 Feb 2003, Samuel Falvo wrote:

    [...]

    > That being said, I've researched some Joy source code, and I'm relatively

    > pleased with what I see.  But DEFINE and LIBRA really stick out like a sore

    > thumb to me.  It's not ... concatenative.

    A notation is concatenative if the concatention of programs

    denotes the composition of the functions which the concatenated

    programs denote. Programs which denote functions are what

    can be on the right hand side of the == in definitions.

    But definitions are not programs, they only define a symbol,

    and what gets executed at runtime is always just the right hand

    side.

    In just about all programming languages, Joy included, the order

    of definitions is rather inessential and subject to only a few

    constraints - such as definition before use, and the like.

    Now it is true that definitions are essentially unary functions

    (which modify the symbol table), and hence can be composed.

    If one wanted to insist that these compositions are also written

    in concatenative notation, then there must not be a separator

    between definions, and then we have the problem of parsing

    a sequence of definitions:

       a == b c d == e f g == h i == j k l b == m n c == o p

    Where does the definition of "a" end? Not after the d, because

    that is the start of a new definition (which incidentally ends

    with f). Now, one could write a parser for stuff like this,

    and users could get used to it. But is there any advantage ?

    I think not - and if there is no advantage in, or reason for,

    departing from ordinary notation, then it should be avoided.

    So, unless someone can think of a good reason, I think that

    in this respect Joy should be conservative, since the

    concatentive notation is already asking a lot from new users.

    > Would it be possible to adopt a syntax like this?

    >

    > MyModule ==

    >   [

    >    [

    >     foo == ....

    >     bar == ....

    >    ] public-defs [

    >     baz == ....

    >     blort == ....

    >    ] private-defs

    >   ] module;

    Yes, it would be possible. But what do you want it to mean?

    If == means what it ordinarily means, then this defines

    "MyModule" as a program which, if it is ever called, will push

    a nested program (or list) onto the stack, and then executes

    "module", whatever that does. Note also that the name "MyModule"

    does not appear on the right side, so this cannot be used

    to enter "MyModule" into the symbol table. And also, this

    entry in the symbol table will also be done at run time ...?

    On the other hand, if == does not mean what it ordinarily means,

    then there must be a way of distinguishing the two cases.

    There are two candidate places for this: Either the == in the

    definition of "foo", and in any later definition, or the

    symbol "module" at the end. Presumably this is then to mean

    that the whole right hand side is to be handled immediately,

    and that it defines "MyModule", "foo", "bar", "baz" and "blort".

    But why make it so difficult for the reader to distinguish

    the various senses of == ?

    So, yes, one can introduce all sorts of styles of definitions,

    but some styles are better than others.

    I hope this clarifies matters for you.

      - Manfred