[E-Lang] ERTP-aware MintMaker

hal@finney.org hal@finney.org
Wed, 14 Feb 2001 14:40:07 -0800

I have a style question about the MintMaker:

>     var delayedMint := null
>     define issuer {
> ...
>            delayedMint makePurse(0)
> ...
>      }
>     define mint {
> ...
>                 to getIssuer :any { issuer }
> ...
>      }
>     delayedMint := mint
>  }

issuer needs to refer to mint, and mint needs to refer to issuer.
This is done by creating this variable delayedMint, and having issuer
refer to delayedMint, then at the end we set delayedMint := mint.

That seems kind of awkward, and will become more so when there are
multiple peer functions which refer to each other.  Is it necessary due
to the new "var" changes to E?  Without that, could you have done:

    define mint := null
    define issuer {
        <refer to mint>
    define mint {
        <refer to issuer>

This seems a bit more natural.

Perhaps, if we are stuck with the delayedMint style, it would be
better to rename delayedMint to mint, and rename the function to _mint
or some such, then do "mint := _mint" at the end.  Everywhere we would
refer to mint rather than to _mint.  For consistency we would do the
same thing with all the functions, such as issuer:

    // forward declarations
    define issuer := null
    define mint := null
    // function definitions
    define _issuer {
        <refer to mint, issuer>
    define _mint {
        <refer to mint, issuer>
    issuer := _issuer
    mint := _mint

It's not all that pretty, but it will simplify the code in the body
of the functions so that it can use the simplest names to refer to the
other objects.