Anonymous classes

1 view
Skip to first unread message


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';

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

Dec 1, 2010, 2:56:39 PM12/1/10
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.

Reply all
Reply to author
0 new messages