cdrick wrote:


    Pragmas *may* only be implemented for methods. It seems to be the case
in Visual Works. Do you want an explanation for methods ?

yes if you can :)


Pragmas are annotations for your methods. This annotations allows the developer to categorize its methods.

For exemple, Lukas uses naming conventions to retrieve "description" methods (in fact, you can now use pragmas but forget that otherwise my explanation is useless :-)). The selector has to start with #description to be a description selector:

Symbol>>isDescriptionSelector
"Answer wheter the receiver is a method selector following the naming conventions of a description selector."
  ^ self ~= #description
       and: [ self beginsWith: #description ]


This is a solution. But sometime, you would like to start a method with 'description' and this should not be a description method (or you do it by mistake).

Pragmas can be used to solve this problem. You then will annotate your method to tell the system that this methods are description methods. You do it like this:

MyObject class>>firstName
  <description>
  ^ MAStringDescription auto: 'firstName' label: 'First name'


Then, when you want to collect all the description methods in a class, you will use the methods in the protocol 'finding' of the Pragma class (class side).

Pragma allNamed: #description in: yourObject class

This returns a collection of Pragmas (compiled methods, selector and class) in which the pragma #description has been used in the class of yourObject.


You can use pragmas with arguments too like in:

<selector: #something inClass: 'a class name'>

only literals are allowed as arguments.

With this, you can find all methods using the pragma #selector:inClass: and you can do whatever you want with the argument values.

Writing this, I noticed that Pragmas means a lot of things for me (I used the word a lot in the mail and for different purposes). I may have to read again a documentation about this but I think the idea is here.

Is it clear ?

beacause I use getters and setters for my iv :)


And pragmas won't help you in my opinion, I don't see any relation :-) Why don't you want getters and setters ?



Hope this is your last question of the day, I already answered 4 of them and I'm tired now :-D


See you soon
_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to