meth m(Z Y)
     fun {F X} [EMAIL PROTECTED] end
  in
     Y = {F [EMAIL PROTECTED] 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

_________________________________________________________________________________
mozart-hackers mailing list                           
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-hackers

Reply via email to