[squeak-dev] Namespaces, Packages: Image available for download, screencast.

Igor Stasenko siguctua at gmail.com
Wed Jul 16 13:40:42 UTC 2008


2008/7/16 Michael van der Gulik <mikevdg at gmail.com>:
> On Wed, 16 Jul 2008 03:24:17 +0300
> "Igor Stasenko" <siguctua at gmail.com> wrote:
>
>> Cool screencast Michael! :)
>
> Thanks. It was actually more difficult than I thought; thinking and talking at the same time is hard!
>
>> I have played with it few minutes to look how it doing things.
>>
>> One thing, which i don't like is how looks a class declaration:
>>
>> self inNamespace: 'Kernel.Classes'
>>       createClass: 'ClassCommentReader'
>>       ofType: 'normal'
>>       superclass: 'ClassCategoryReader'
>>       instanceVariableNames: ''
>>       classVariableNames: ''
>>
>> to what 'self' refers to?
>
> Er... usually an instance of CodeBuilder.
>
>> Do you plan to allow creating classes by subclassing existing ones,
>> e.g. by sending a messages to them, like in regular smalltalk?
>
> That could be done; I'm not particularly happy with the syntax myself. It is not very Smalltalkish.
>
> I think my original idea was to put an absolute minimum of functionality in Class, ClassDescription and Behavior for <waves hands in air> security. I think that may have been a bit misguided, because being able to make a subclass is possibly a benign operation.
>
> Also, it keeps all code definition methods in one class, so that at some stage later, that class (CodeBuilder) could be used as a capability.
>
> For now, the code is there and works and can be refactored later. I want to get SecureSqueak working first, and then I'll revisit ugly things like this.
>
>> To my understanding, the above should look like:
>>
>> Kernel.Classes addClass: (
>>    Kernel.Classes.ClassCategoryReader subclass: #ClassCommentReader
>>    type: 'normal'
>>    instanceVariableNames: ''
>>    classVariableNames: ''
>> ).
>
> This looks much more logical, but the problem here is that all globals need a context, meaning that any packages, namespaces, classes and shared variables that you refer to need to be included in the import list of the importer. That could be done, but it is less elegant than what I did above.
>

Sure, but in SecureSqueak, you always compiling code in some context -
some instance of Namespace, which is first which will be asked for
returning a symbol's associated value.
So, for a file-ins you have to work out (if you don't have it already)
the model, how to switch to different namespace, before compiling some
code.
In same manner, as you open 'Scoped workspace' , all fileins should be
scoped as well.
And since browser is scoped already, the code above should be
interpreted just fine by compiler.

One more thing is about namespace imports. I find it not quite
convenient in having each namespace keep own imports.

This could lead to complexity issues:
Suppose package having 10 namespaces, and each one of them could have
own list of imports. And there can be probability that two different
namespaces importing two different versions of same package. This
means, that by occasion, developer can make his package depending from
some Package X v1, and Package X v2, which i think can't be his real
intention :)
I think it would be better to make only packages having imports, and
regular namespace should have only parent.

So, the definition here is superfluous:

IdentityDictionary subclass: #Namespace
	instanceVariableNames: 'name imports package fullyQuantifiedName parent'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Namespaces'

it should be only:

IdentityDictionary subclass: #Namespace
	instanceVariableNames: 'name parent'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Namespaces'

fullyQuantifiedName can be computed based on name + parent(s).
Also, i don't see a real need in having namespace directly pointing to
package. Package is the root parent of namespace, isn't? So it can be
computed at any time. Why referencing to it directly?

And then Package could add new 'imports' ivar.

Namespace subclass: #Package
	instanceVariableNames: 'uuid deserializeSemaphore readOnly imports'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Namespaces'

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list