# Semantics of abort and newstack

## Joel Kelso — 2001-10-22 13:13:27

    First let me apologise if this has already come up (I couldn't find

    it in the archive).  I was just thinking about the identification of

    the left and right zeroes of the Joy algebra, and their association

    with 'abort' and 'newstack' .

     From the Joy mathematical foundations paper:

      > ...  It is appropriate to remark here that there is also a left zero

     > element and there is a right zero element. Two such elements l and r

     > satisfy the following for all programs P:

     l  P   ==   l                   P  r   ==   r

      > Since function composition is not commutative, the two zero elements

     > are not identical. In Joy the left zero l is the abort operator, it

     > ignores any program following it. The right zero r is the clearstack

     > operator, it empties the stack and hence ignores any calculations that

     > might have been done before. The two operators have some theoretical

     > interest, and they are occasionally useful.

     Am I right in thinking that if 'newstack' is a right zero in Joy (and

    we want it to be defined everywhere), then 'abort' must be the function

    that is not defined anywhere ?  Otherwise

       abort == abort newstack == newstack

    causes problems for 'newstack'.  Does that mean that 'abort' is also

    a right zero and, barring side effects, any concatenation including

    'abort' is the same ?

    Joel Kelso (chiral@...)

## Manfred von Thun — 2001-10-23 03:48:02

    On Mon, 22 Oct 2001, Joel Kelso wrote:

    Thanks for the interest! It is good to hear that people do read

    the theoretical material on Joy.

    > First let me apologise if this has already come up (I couldn't find

    > it in the archive).  I was just thinking about the identification of

    > the left and right zeroes of the Joy algebra, and their association

    > with 'abort' and 'newstack' .

    >

    >  From the Joy mathematical foundations paper:

    >

    >  > ...  It is appropriate to remark here that there is also a left zero

    >  > element and there is a right zero element. Two such elements l and r

    >  > satisfy the following for all programs P:

    >

    > l  P   ==   l                   P  r   ==   r

    >

    >  > Since function composition is not commutative, the two zero elements

    >  > are not identical. In Joy the left zero l is the abort operator, it

    >  > ignores any program following it. The right zero r is the clearstack

    >  > operator, it empties the stack and hence ignores any calculations that

    >  > might have been done before. The two operators have some theoretical

    >  > interest, and they are occasionally useful.

    >

    > Am I right in thinking that if 'newstack' is a right zero in Joy (and

    > we want it to be defined everywhere), then 'abort' must be the function

    > that is not defined anywhere ?

    No, I think a good way to think about it is this:

            abort 44 55 66   ==   id

    >  Otherwise

    >

    >    abort == abort newstack == newstack

    >

    > causes problems for 'newstack'.  Does that mean that 'abort' is also

    > a right zero and, barring side effects, any concatenation including

    > 'abort' is the same ?

    No, for example

            11 22 33 abort 44 55 66      =>   11 22 33

    And combining that with my earlier response,

            11 22 33 abort 44 55 66

        ==  11 22 33 id

        ==  11 22 33

    It would have been possible to let abort clear the stack too.

    But I decided against that because after the abort the so far

    computed stack might be useful for debugging purposes.

    > Joel Kelso (chiral@...)