forked from Mirror/wren
Add trivial fib benchmark.
This commit is contained in:
29
doc/implicit fields.txt
Normal file
29
doc/implicit fields.txt
Normal file
@ -0,0 +1,29 @@
|
||||
Q: Can fields be implicitly declared?
|
||||
|
||||
The idea is that just using a name starting with "_" somewhere in a class
|
||||
automatically defines a field with that name. Implicit fields are particularly
|
||||
nice because it means they don't have to be defined all before methods. (Since
|
||||
we have a single-pass compiler, we would have to otherwise a method could
|
||||
only refer to previously defined fields.)
|
||||
|
||||
One potential problem is with nested classes. This is more important if we
|
||||
consider a module effectively a class. Consider:
|
||||
|
||||
class Outer {
|
||||
foo {
|
||||
_blah = "value"
|
||||
}
|
||||
|
||||
class Inner {
|
||||
io.write(_blah) // Does this declare field in Inner, or access Outer?
|
||||
}
|
||||
}
|
||||
|
||||
Looking at this, though, I think there's already a question how referring to an
|
||||
outer field would work. Having an instance of Inner doesn't imply you also have
|
||||
an instance of Outer. We definitely don't want to recapitulate inner classes
|
||||
in Java.
|
||||
|
||||
Q: What about static fields?
|
||||
|
||||
A: Different naming convention? __foo?
|
||||
Reference in New Issue
Block a user