Next: , Previous: , Up: actor-lib: A standard library of sorts   [Contents][Index]


6.15 Simple Mint

The (goblins actor-lib simple-mint) module provides an example actor simulating a mint and currency. This is a Goblins implementation of a classic example of object capabilities.

Constructor: ^mint _bcom

Constructor an actor which in turn constructs and returns purses for its currency. A mint only has one method: new-purse initial-balance spawns and returns a reference to a new purse which holds initial-balance tokens.

A purse, on the other hand, has four methods:

  • get-balance: Return the current number of tokens in the purse.
  • sprout: Spawn and return a reference to a new empty purse for this currency.
  • deposit amount src: Increase the number of tokens in this purse by amount, decreasing the number of tokens in the purse of the same currency src by the same amount.
  • get-decr: Return a procedure accepting one argument, an amount of tokens to remove from this purse.
Procedure: withdraw amount from-purse

Spawn and return a reference to a new purse holding amount tokens of the same type as the purse from-purse. Remove the same numbers of tokens from from-purse.

Persistence Environment: mint-env