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'



yes that's why I fiind that interesting.. clearer


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.

this is cool ;)  I'm manipulating them a bit right now



Is it clear ?

yes more thanks ;)


> 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 ?

yes I wasn't clear. But as accesors are methods, I can use pragma to
tag indirectly my instance variable. Just an idea of somethink that
can be useful to me.
I trying to make a kind of (small) knowledge management system, maybe
more a kind of case based reasoning tool (ie. entities are composed of
attributes or descriptors upon which the system reason..) and one
simple solution for me is to directly use instance variables for these
descriptors (and then I can tag to process them)...

I'm trying to see all kind of solution I could choose... even if right
now I'm more trying to use dedicated Descriptor class...

I think one of the limitation I have (but I'll probably open a post on
that one day) is that I need attributes as first-class entities and
instance variable are not (are they ?)



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

this was ;)  I have days like that  :d

Squeak REALLY rocks

Cédrick
_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to