Re Torbjörn Re: Features wanted (0$ reward)
Björn Hägglund
bjohag at home.se
Thu Dec 1 08:23:16 CET 2005
> meth m(Z Y)
> fun {F X} X*@a end
> in
> Y = {F {@f Z}}
> end
Yes, this is good if you want an auxiliary function used by only that
method. But what if you want an auxiliary function that is shared by 3
methods out of, say, 50 methods. Then it would be nice to be able write
things like this inside a class definition:
local
fun {Aux X}
<some expression perhaps involving attributes>
end
in
meth m1(...)
<statement calling Aux>
end
meth m2(...)
<statement calling Aux>
end
meth m3(...)
<statement calling Aux>
end
end
Writing it like this also makes it clear that Aux does not have direct
access to the method parameters.
> class A
> attr
> f: fun {$ X} X*X end
> end
Using this style just to express that a function is local to a class is not
elegant enough for the following two reasons: You need to use an attribute
access to call the function and the syntax for that deviate too much from
ordinary function calls. And what's more, a cell is implicitly created,
which gives the impression that the function might be destructively changed.
These issues are certainly not deadly important. But why not make things
perfect...
.Björn
More information about the mozart-hackers
mailing list