Kevin Smith wrote:
Hi Alex,
Opinions are opinions, sure, but in the real-world example that I
posted, "this." appears a staggering 49 times. And that's for a
relatively simple class. Tastes aside, eliminating that repetition
would offer quantifiable benefit.
Since foo.@bar is a candidate for private name, you can suggest
- @ itself to be abbreviation to this. But it is grawlixy, I don't know
if people will like the code like this:
function SkinnedMesh(geometry, materials) {
THREE.Mesh.call(@, geometry, materials);
@.identityMatrix = new THREE.Matrix4();
@.bones = [];
@.boneMatrices = [];
// ...
};
not to mention that private access would be @.@foo.
- another suggestion (use another char for 'this' or glued with foo as
replacement for 'this.foo')
- one thing I came with is to use '()' in place of this. Also a bit
grawlixy, but can have some logic to it (empty parentheses returning the
default value, which is this since we're OO :-) ), the code may look
like this:
function SkinnedMesh(geometry, materials) {
THREE.Mesh.call((), geometry, materials);
().identityMatrix = new THREE.Matrix4();
().bones = [];
().boneMatrices = [];
};
which is maybe readable... but grawlix-dislikers would not like it (I
also do not like grawlix too much. like in perl) and shorteners will
probably not be happy that is only saves two chars per this.
It's not clear that obj.@name would offer any such benefit. If anyone
has done any research, I would be glad to know.
I just want to make sure the numbers are out there.
kevin
Herby
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss