[E-Lang] the return of `return'
Darius Bacon
darius@accesscom.com
Tue, 19 Jun 2001 01:32:45 -0700
Dean Tribble <tribble@e-dean.com> wrote:
> A good reason to consider it too clever. Perhaps the more verbose, but
> simpler, example below?
>
> def fooMaker(x) {
> def foo {
> to blat() { ... }
> }
> return foo
> }
This looks like something I could live with. Let's try the MintMaker
in the same style:
def MintMaker(name) {
def [sealer, unsealer] := BrandMaker pair(name)
def mint {
to printOn(out) { out print(`<$name's mint>`) }
to makePurse(balance :(integer >= 0)) {
def decr(amount :(0..balance)) {
balance -= amount
}
def purse {
to printOn(out) { out print(`<has $balance $name bucks>`) }
to getBalance() { return balance }
to sprout() { return mint makePurse(0) }
to getDecr() { return sealer seal(decr) }
to deposit(amount :integer, src) {
unsealer unseal(src getDecr())(amount)
balance += amount
}
}
return purse
}
}
return mint
}
All right... when I started this thread I thought all the `return'
alternatives sucked, but I was wrong. (I still like the current E
better, personally.) Just for fun, let's try another small change to
the language: :-)
def MintMaker(name) {
def [sealer, unsealer] := BrandMaker.pair(name)
def mint {
to printOn(out) { out.print(`<$name's mint>`) }
to makePurse(balance :(integer >= 0)) {
def decr(amount :(0..balance)) {
balance -= amount
}
def purse {
to printOn(out) { out.print(`<has $balance $name bucks>`) }
to getBalance() { return balance }
to sprout() { return mint.makePurse(0) }
to getDecr() { return sealer.seal(decr) }
to deposit(amount :integer, src) {
unsealer.unseal(src.getDecr())(amount)
balance += amount
}
}
return purse
}
}
return mint
}
There! Happy now, Zooko?
-Darius