Using f: => Boolean instead of f: Boolean likely implies operational
semantics which requires the argument to be managed by the GC. The
workings of the JVM GC likely require the value to be stored in some
field somewhere.
This is just a wild guess, though.
--
Guillaume Yziquel
You should perhaps try replacing
> > val prop = Convert.asHumanStringFunc(b.someProperty)
by the following
val prop = {
val bb = b
Convert.asHumanStringFunc(bb.someProperty)
}
and check whether or not the field is still present. With a little luck,
it should disappear.
As to the public qualifier, I suspect that it's because you haven't
specified b as being private[this] that the field ends up being public
as soon as his presence is deemed necessary for runtime reasons (i.e.
lazyness of f: => Boolean). After all, public is the default.
--
Guillaume Yziquel
Am Montag, 20. Februar 2012, 14:43:54 schrieb Alexey Goncharuk:
Hello Alexey - I am not sure what you want to achieve exactly - maybe something like this:
Welcome to Scala version 2.9.0.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :paste
// Entering paste mode (ctrl-D to finish)
object Test {
def render(source: =>Boolean): String = source.toString
def test() {
var bool = false
val renderme = () => render(bool)
println(renderme())
bool = true
println(renderme())
}
}
// Exiting paste mode, now interpreting.
defined module Test
scala> Test.test
false
true
I guess you expect "val prop" to be a function object which it isn't. It gets evaluated at once and contains an immutable String value.
Greetings
Bernd