Namespace, Package, Classbox and Local Rebinding

Alexandre Bergel bergel at iam.unibe.ch
Sat Apr 17 11:18:55 UTC 2004


This email complement Stef's answer.

> 	1. Letting independent modules use the same short names for a class?

There is no qualified name. Dependencies between classboxes are specified __only__ when importing.

> 	3. Letting users start coding quickly?  e.g., how much overhead is
> there to create a dumb little subclass of Morph that responds to button
> clicks by opening a web browser?

Evaluate the following in a workspace after having loaded Classbox from SqueakMap and evaluated 'Classbox hookClassboxModel'
Note that the two last expressions are equivalent in that example.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|cb|
cb := Classbox create: #MyGreatButtonClassbox.
cb import: #Morph from: Classbox system.
cb import: #PluggableButtonMorph from: Classbox system.
cb import: #Transcript from: Classbox system.
cb createClassNamed: #MyGreatButton superclass: #Morph.

cb addMethod: 'initialize
  super initialize.
  self addMorph: (PluggableButtonMorph on: self).
  self bounds: ((100 @ 50) extent: (100 at 50))' for: #MyGreatButton.
cb addMethod: 'isOn ^true' for: #MyGreatButton.
cb addMethod: 'switch Transcript show: ''Blah blah'';cr' for: #MyGreatButton.
cb addMethod: 'open self new openInWorld' for: #'MyGreatButton class'.

cb evaluate: 'MyGreatButton open'.
(cb at: #MyGreatButton) open
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Please note that a (buggy) browser is provided. It is far from being complete. Actually I have done it in order to do some classboxes demo. However, when programming with the browser you do not need to explicitely import needed classes, when you reference in a method a Class not visible within the classbox, when the browser ask you when do you want to import this class from. 

> 	4. Letting users manage the system after it has been running a while
> and acreating any gunk that #3 will impose?

I do not understand it. I have an English question, what is a "gunk"?


> I do not see a way to import namespaces as a whole.  This seems bad. 

In the current implementation we cannot import a classbox as a whole.

> How do I write code that uses Tweak classes, from outside of Tweak,
> without having to fully qualify all of my references?  Am I forced to
> import one class at a time?

If you want to use a class A provided by a classbox CB1 in your classbox CB2, you need to import it.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|cb1 cb2|
cb1 := Classbox create: #CB1.
cb1 import: #Object from: Classbox system.
cb1 createClassNamed: #A.

cb2 := Classbox create: #CB2.
cb2 import: #Object from: Classbox system.
cb2 import: #A from: cb1.
cb2 createClassNamed: #B.
cb2 addMethod: 'getNewA   ^A new' for: #B.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Doing it by hand might be painful. But the tools should be there to automatize this task.
Look at the method Classbox>>interactivelyAddMethod: aString for: aClassname
When a reference is not found, then a popup menu appears...


>  Or am I expected to write all Tweak-using
> code inside a Tweak namebox?  What if I want classes from two separate
> class boxes?

could be something like:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
cb3 := Classbox create: #CB3.

cb3 import: #Object from: cb1.
"Equivalent to:
cb3 import: #Object from: Classbox system.
or
cb3 import: #Object from: cb2."

cb3 import: #A from: cb1.
cb3 import: #B from: cb2
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



> What do you mean that they help with deployment?  I am not aware of any
> deployment problem in Squeak that can be addressed at the language
> level.  So I guess I am asking: what do you mean of deployment? 
> Deployment of what and to whom?

The meaning given to the word "deployment" is important. If it just means sending some code without caring if the code is installable and runnable in a different image than mine, than changeset are well enought. But in that case there is no dependency, and if the load breaks in the middle, you are gone. I also put aside the issue related to uninstall a changeset.

Monticello does far better. But my feelings is more works are needed. For instance, dependencies has to be set up manually, and so whatever the code contained in a package. This mean that I can create a ButtonMorph in my package but setting a dependency with the Network package rather than with Morph for instance. 

The second point is about unloading package. As far as I have seen (but please let me know if I am wrong), Monticello does not manage that properly in the sense that: if I load sequentially 10 packages that override a method foo, unloading some of them does not always give an expected result. If I am wrong, please show it to me with a SUnit test.

And my last point regarding packaging system is about how class extension are managed. What do you think about this question: "Whatever the packages installed in my system, I want to be sure that loading my dummy package do not make the system uninstable". This means that if in your squeak you have an application managing a nuclear powerplant, _loading_ a "EvilClassbox" should not break or disturbe anything. If you load a package in a separate namespace, there is no class name-clashing. So the issue is about class-extension. If in your EvilClassbox you have a method extension 'warmWater ...' on the class SwimmingPool, redefining this method should not perturb other applications. Classboxes manages this issue by having class extension visible to the classbox that defines it.

I think that these 3 points make code-deployment a hard task. The classbox model unifies the notion of package, the notion of namespace, and the notion of locality[*]. It is true that the two first notions looks orthogonal (for instance in moose, a big VisualWorks application, there is only one namespace and a myriad of packages). But in some other hand the advantage of having one namespace per package leads to a simple model with only one entity.

Me feeling is that Goran's namespace answers very well the problem of class-name conflict without disturbing and changing habits. But I am sceptical about sharing code with other people. I am not saying it is impossible, of course it is. VisualWorks does it. But in a complicated way...

Cheers,
Alexandre

[*] Similar to namespace selector but the local rebinding facility gives far more expressiveness. If some of you are interested about this point, I can explain more.

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.iam.unibe.ch/~bergel
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



More information about the Squeak-dev mailing list