Anonymous classes

1 view
Skip to first unread message

nickf

unread,
Dec 1, 2010, 1:36:07 PM12/1/10
to Joose
Is there any functional different between these two code blocks?
(assume that

Class('myNamespace.MyClass', { ... })

// assume that the full namespace is always constructed properly
myNamespace.MyClass = Class({ ... });
myNamespace.MyClass.meta.name = 'myNamespace.MyClass';

Despite the second option looking more repetitive, for my particular
use of Joose, it would save a bit of redundancy. I just wanted to know
if there were any other side-effects?

Nickolay Platonov

unread,
Dec 1, 2010, 2:56:39 PM12/1/10
to joos...@googlegroups.com
Yes, there will be a small difference in the following case. Joose uses special placeholders for namespace chains, so this is possible:

Class('Some.Class', {})

var a = new Some.Class()

Class('Some', {})

var b = new Some()

So you can use the initial namespace segment for class (or role) just fine. When creating namespaces manually you need to care about that yourself.

Otherwise should be no differences.

Nickolay
Reply all
Reply to author
Forward
0 new messages