On 17.06.2009, at 16:16, Bernardo Ezequiel Contreras wrote:
where can i find Pragma? do you have a link? because i couldnt find it.
Pragma is a class. Can be found in Squeak 3.9 and Pharo, it was introduced to Smalltalk in VisualWorks, I think, and brought to Squeak by Lukas in 3.9 (put on top of a property interface for methods inspired by Tweak). The idea is the following: In Smalltalk, there is a special syntax for Primitives: + aNumber <primitive: 1> ^ super + aNumber Why not provide a more general concept where we can use the <selector: arg> syntax to put meta-annotations in methods? And that's what pragmas are. (Conversely, in Squeak 3.9 and Pharo, primitives are pragmas and not special syntax). tt <hello: #world> is perfectly fine. For what can this now be used? One idea is meta- annotations. For example, SLint is a useful code-critic tool. But sometimes, it's wrong. So you can put a Pragma that communicates to SUnit: please don't report the problem X, because I decided it is none. Another example would be the MethodFinder. The example-mode of the method finder allows you to give an example and executes all methods of the system to find one that does what your example requests. e.g. 3. 4. 7 it finds 3 + 4, 3 bitOr: 4 and 3 bitXor: 4. Of course, executing just every method could lead to problems if the method has side-effects. (Like, quitting the image). Thus, the MethodFinder has lists of methods that should not be called (#noteDangerous). Of course, this means that all selectors are hard-coded. And one can not use this valuable information for other cases. One thing to think about would be to add a "this method has a bad side- effect" annotation. (maybe. Maybe this will not scale and just clutter the system. But it's worth a try). Back to Pragma: on the class-side there are some convenience methods, e.g. Pragma allNamed: #primitive: in: SmallInteger returns all pragmas in class SmallInteger. (and the pragma references the method it is installed in, which in turn knows it's class and selector). Marcus -- Marcus Denker - http://marcusdenker.de PLEIAD Lab - Computer Science Department (DCC) - University of Chile