Closed iccir closed 5 years ago
My current thought process:
@dynamic
must be used to show intent. @synthesize foo=_foo
may also be used (or maybe it should error?)..md
file which documents these types of differences between Obj-C and NilScript.@synthesize foo=mFoo
for his ivars.Here's the updated spec:
@synthesize
, warn (this is the same as in 2.x)warn-inherited-ivars
compiler option will warn if an inherited ivar is used directly.Oops, I forgot to add information about the new --simple-ivars
compiler flag. When set, the NilScript compiler will use 'this._foo' to refer to the '_foo' ivar, rather than 'this.N$_i__foo'. This should make debugging easier.
Per the documentation:
As long as ivars are prefixed (either the default _theIvarName or the non-standard prefixes such as m_theIvarName or mTheIvarName), this should be safe. You may run into issues if you use this flag and also use an ivar name which conflicts with an Object.prototype property. Examples include: constructor, hasOwnProperty, toString, valueOf, etc.
--simple-ivars has no effect when the squeezer is enabled.
Currently, we mimic Objective-C's "the same name can refer to multiple ivars". For example:
In the above,
_foo
can either refer toTheSubclass
's ivar (currently$oj_i_TheSubclass$_foo
) orTheSuperclass
's ivar (currently$oj_i_TheSuperclass$_foo
), depending on where you use_foo
.This is something that we've never gotten right (#127), and it's also a confusing behavior of Objective-C. Worse, it makes debugging difficult due to including the class name inside of the backing JavaScript variable.
We should reevaluate for NilScript 3.