DeltaModules vs Envy/Ginsu Class Extensions (was Re: Squeak
squeak-dev at lists.squeakfoundation.org
Sat Oct 19 07:45:03 UTC 2002
but in parcel or packages in VW you can change override methods and t=
shape of the classes too which is really trickier.
Now you can also add conceptually a namespace to a envy applications=
and you get the unload facilities, this is what was
used in VW30 to have parcel unload and automatic load. This is great=
you can load the parcels in any order the prereq are loading
if they are found if one is missing at the end everyhitng is unloaded=
or not installed.
> With Envy/Ginsu-style modules (which I assume are similar to what R=
> & Steph are talking about), modules can contain classes, and can al=
> contain "Class Extensions" (a.k.a. loose methods). I would define=
> Class Extensions as methods which are additions to classes in other=
> modules, but they are ONLY additions, NOT changes to existing metho=
> (and not removals either).
> DeltaModules, on the other hand, can contain method additions, but=
> also changes to existing methods and method removals too.
> So, to generalize a bit, DeltaModules are more powerful, but Class=
> Extensions are quite a bit simpler.
> Let's think about a couple of useful properties of modules:
> 1. Can they be cleanly unloaded?
> 2. Are they behavior-preserving? In other words, if you load (and=
> activate) a module, will the rest of the system still run without=
> breaking or behaving differently?
Yes this is a key point. We worked on something that we called classB=
that add some nice properties but also some wrong ;)
> Regarding #1, 3.3a-style Modules and DeltaModules can be unloaded, =
> Envy/Ginsu-style modules can too, so no problems there. Changesets=
> cannot be unloaded, which is their big limitation.
> Regarding #2, this is one reason for the split between Modules and=
> DeltaModules in 3.3a. If you load a Module (with no DeltaModules),=
> the rest of the system will be unaffected, so they are=20
> behavior-preserving. DeltaModules are not behavior-preserving, but=
> that's the point of them... they can be used if you do need to chan=
> something else in the system.
> Because DeltaModules are not behavior-preserving, they naturally ha=
> to change version numbers of the Modules that they modify. So for=
> example if a WebBrowser Module has a DeltaModule which adds the met=
> #asEncodedHtml or changes a method in class String, in the Module=
> "Kernel 2.7", the Kernel module will need to be assigned a new vers=
> number such as 2.8. (I believe this is how DeltaModules are suppos=
> to work, correct me if I'm wrong.) This may have big implications =
> the rest of the modules in the system, which might expect to run on=
> Kernel 2.7 but not know about 2.8.
> But the interesting thing is, Envy/Ginsu-style modules w/Class=20
> Extensions *are* behavior-preserving, with a few caveats* (see bott=
> of message). This is because, in general, if you add a new method =
> an existing class, none of the rest of the system would ever send t=
> new method, so the behavior of the rest of the system is unchanged.=
> So, reusing the example above, if a WebBrowser module has a Class=
> Extension which adds the method #asEncodedHtml (but does not change=
> any method) in class String, in the module "Kernel 2.7", the Kernel=
> module will still remain 2.7. (This is exactly what Envy does. I=
> don't remember now if Ginsu supports version numbers.)
Exact we try to see how a class extension could be only working for t=
module that define it but in case of method modification
that the system only calls your modification when you were invoking t=
other methods that would call the method you changed.
It worked but we were not satisfied. Roel cna explain that at OOPSLA
> The other question is then, if we're using Class Extensions, is it=
> good enough to only be able to *add* methods to classes in other=
> modules, not modify/remove them (as DeltaModules can do)?
> Well, I guess that's a big question. :-) I would say that most of =
> time, yes, it's good enough. A module does not often need to=20
> change/remove methods in other modules, unless we're directly fixin=
> bug in that other module. Adding methods is much more useful, and =
> be specific to the "outer" module (such as the example WebBrowser=
> module adding #asEncodedHtml to String). People who've used Envy k=
> that it can be very handy... although you don't want to abuse it to=
> With Envy/Ginsu, if your module *really* needs to change/remove a=
> method in Kernel 2.7, you make your own private version of Kernel 2=
> with the change, and/or you lobby the maintainer of Kernel to make =
> change. But this should be relatively rare aside from bug fixes.
> On the other hand, the ability of DeltaModules to handle method=
> changes/removals could be quite nice. And they seem a bit more=
> rigorous, no "caveats" as with Class Extensions below. And namespa=
> are already built-in. But there is extra complexity cost... For=
> example, DeltaModules have to worry about activation/deactivation,=
> with Class Extensions it is irrelevant. The Class Extensions are=
> always active when the module is active, since they don't affect=
> anything else.
I think that supporting modification of methods is cool but makes=
things much more complex. Same for changing the shape of a class.
> One last thing: As far as splitting up the current Squeak image int=
> modules goes, my hunch is that it would be easier to do with=20
> Envy/Ginsu-style modules. This is because you would not need the=
> DeltaModule capability of specifying changed/removed methods when=
> divvying things up, only the ability to specify added methods, whic=
> the lighter-weight Class Extensions can also handle without version=
> number worries. For example, String>>asMorph could be quickly dump=
> into some Morphic module.
> (Avi, are the DVS "logical modules" similar to Envy/Ginsu with Clas=
> Am I making sense here? This message is getting too long, sorry. =
> me know if I've characterized one of the approaches incorrectly. A=
> I know this is only one aspect of the differences between these two=
> module systems. Anyway, I've often found that I learn more by see =
> things compared against each other, than by seeing them described=
> - Doug Way
> dway at riskmetrics.com
> *Caveat #1: There could be namespace conflicts with Class Extension=
> which Envy/Ginsu don't handle. I'm guessing that adding namespace=
> support is one thing that Roel & Steph were working on?
Yes I can send you a so not good paper :)
> *Caveat #2: Ideally, to preserve behavior, you would not allow a Cl=
> Extension to override a method in a superclass. This would be a=
> simple restriction to add. Otherwise, you could bring an image to =
> knees by adding a new method #size to SortedCollection which return=
> nil. :-)
this is price for freedom
> *Caveat #3: If a base module class is doing something funky with=
> reflection such that adding a new method changes its behavior, then=
> the Class Extension might not be behavior-preserving. But this fal=
> under the category of Very Rare, IMHO. (I guess an example might b=
> adding a testXXX method to an SUnit test suite class.)
Dr. St=E9phane DUCASSE (ducasse at iam.unibe.ch)=20
"if you knew today was your last day on earth, what would you do
different? ... especially if, by doing something different, today
might not be your last day on earth" Calvin&Hobbes
More information about the Squeak-dev