[Grace-core] thinking about private

Andrew P. Black black at cs.pdx.edu
Thu Dec 6 10:34:44 PST 2012


On 6 Dec 2012, at 06:34 , Lex Spoon wrote:

> I would be hesitant to distinguish between methods and fields. In this
> case, note that defs and vars can have initializers,

One important difference between a method and a def field is that the def field is evaluated exactly once (at object creation time, not initialization time), whereas the method is evaluated every time it is requested.

	method makeOne.new(p) {
		object {
			def g is public, readable = some.function(p)
			method h { some.function(p) }
		}
	}


	def o = makeOne.new(4)
	o.g  // answer the pre-computed result of some.function(p)
	o.h  // recomputes some.function(p) and returns the answer




More information about the Grace-core mailing list