[Pharo-project] PackageInfo named: creates one if doesn't exist....confusing

Mariano Martinez Peck marianopeck at gmail.com
Fri Nov 26 16:12:50 CET 2010


Hi folks.

PackageInfo >> named: aString
    ^ PackageOrganizer default packageNamed: aString ifAbsent: [(self new
packageName: aString) register]

creates a new one when it doesn't exist, instead of throwing an error. This
has already driven me to different problems difficult to debug.

What about doing something like:

PackageInfo >> named: aString  ifAbsent: aBlock
    ^ PackageOrganizer default packageNamed: aString ifAbsent: [aBlock
value]

PackageInfo >> namedForcingNew: aString
    ^ self named: aString ifAbsent: [(self new packageName: aString)
register].

PackageInfo >> named: aString
    ^ self named: aString ifAbsent: [Error signal: 'The package: ', aString,
' doesnt exist'].


The other option is to directly change PackageOrganizer and implement there:

PackageOrganizer >> packageNamed: aString
    ^ packages at: aString ifAbsent: [Error signal: 'The package: ',
aString, ' doesnt exist'].

With this one the only non confortable is that to use it, is longer...you
have to do:

PackageOrganizer default packageNamed: 'ZarazaPackage'

but it is safer than changing PackageInfo>>named

Cheers

mariano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20101126/cf1fb4a4/attachment.htm>


More information about the Pharo-project mailing list