Sorry for the noob questions...
What do you do if you want to import 2 discreet packages into your image and each contains a class of the same name? |
El mié, 17-11-2010 a las 20:12 -0800, Jeff Gray escribió:
> Sorry for the noob questions... > > What do you do if you want to import 2 discreet packages into your image and > each contains a class of the same name? As Squeak/Pharo haven't namespaces, you should modify some of them to other name so that they don't clash. Either rename the class to something different of add a prefix to one of them. This is the reason why many packages start by choosing a prefix (2 or 3 chars) that are used in all the classes of the packages: W* for Seaside Ma* for Magma classes etc. If you have a .st file with the source code of one of them then open it in a good text editor and add a prefix to all the classes. Or load one package in an image, refactor the classes to a new prefix and then load the second package. You can also explore the namespaces implementation that was developed in the last google summer of code. A presentations and a screencast was available. Search the archives for them. Cheers -- Miguel Cobá http://twitter.com/MiguelCobaMtz http://miguel.leugim.com.mx _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
Hi,
I'm an experienced Java developer and I code in Smalltalk in my spare time. I'm used to using namespaces to structure my code with Java and the lacking of it in Smalltalk was never a problem for me. By my exprience, I don't think namespace support is necessary or a good think. The lacking of namespace support forces developers to think (and thus to name) their class in a more strongly way: a class name should vehicle the concrete (technical or business) concept it represents and simple name should be avoided. Event the most general concepts depend upon the context in which they are used, so their name should be prefixed by a name or keyword that identifies this context. This is just my humble opinion. Mig Le 18/11/2010 05:43, Miguel Cobá a écrit : > El mié, 17-11-2010 a las 20:12 -0800, Jeff Gray escribió: >> Sorry for the noob questions... >> >> What do you do if you want to import 2 discreet packages into your image and >> each contains a class of the same name? > As Squeak/Pharo haven't namespaces, you should modify some of them to > other name so that they don't clash. Either rename the class to > something different of add a prefix to one of them. This is the reason > why many packages start by choosing a prefix (2 or 3 chars) that are > used in all the classes of the packages: > > W* for Seaside > Ma* for Magma classes > > etc. > > If you have a .st file with the source code of one of them then open it > in a good text editor and add a prefix to all the classes. > Or load one package in an image, refactor the classes to a new prefix > and then load the second package. > > You can also explore the namespaces implementation that was developed in > the last google summer of code. A presentations and a screencast was > available. Search the archives for them. > > Cheers _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
Free forum by Nabble | Edit this page |