[Grace-core] thinking about private

Lex Spoon lex at lexspoon.org
Thu Dec 6 06:34:00 PST 2012


Using closure-captured variables instead of object members can make
for really clean code. An important special case is the use of
parameters to the makeFoo method. They are like free private fields.

I would be hesitant to distinguish between methods and fields. In this
case, note that defs and vars can have initializers, and for that
reason you might still want to put them in the object rather than in
the makeFoo scope. Also, note that sometimes you can profitably pull a
method out into the makeFoo scope.

For what it's worth, people use private in Scala very frequently. I
guess that's not surprising given how much it emphasizes classes.

Lex


More information about the Grace-core mailing list