Hi all..
I've got an odd question but figured I'd ask regardless... I'd like to have one method in a class that could have a pragma in it (see examples below) and I'd like to be able to ask the Pragma class if method #foo has a particular pragma present in it.. However, all of the methods in the pragma class look for pragma's across the entire class.. Is the best way to achieve this to call the existing method and then review the output to see if the method name matches or is there a better way..? Below is example w/ pragma : FooBar>>fooGroup1 <subform: #foobarbaz> <label: 'group #1'> ^ self fooValues Ideally I'd like to be able to do something like -- not sure the syntax makes sense: t := (Pragma allNamed: #subform: inMethod: fooGroup inClass: FooBar). Thanks in advance... _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi Richard,
if you have the method, then this would be an instance of AnnotatedMethod, which again has attributes. These attributes are the pragmas that are defined in this method. The class Pragma itself is used mostly for finding the methods of a class that contain a certain pragma. Kind Regards Karsten Richard E. Flower wrote: > Hi all.. > > I've got an odd question but figured I'd ask regardless... > > I'd like to have one method in a class that could have a pragma in it > (see examples below) and I'd like to be able to ask the Pragma class > if method #foo has a particular pragma present in it.. However, all of > the methods in the pragma class look for pragma's across the entire > class.. Is the best way to achieve this to call the existing method > and then review the output to see if the method name matches or is > there a better way..? > > Below is example w/ pragma : > > FooBar>>fooGroup1 > <subform: #foobarbaz> > <label: 'group #1'> > ^ self fooValues > > Ideally I'd like to be able to do something like -- not sure the > syntax makes sense: > > t := (Pragma allNamed: #subform: inMethod: fooGroup inClass: FooBar). > > Thanks in advance... > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > > > -- Karsten Kusche - Dipl.Inf. - [hidden email] Tel: +49 3496 21 43 29 Georg Heeg eK - Köthen Handelsregister: Amtsgericht Dortmund A 12812 _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Rick Flower
> > FooBar>>fooGroup1 > <subform: #foobarbaz> > <label: 'group #1'> > ^ self fooValues > > compiledMethod := (FooBar findSelector: #fooGroup1) last. form := compiledMethod attributeAt: #subform ifAbsent:[self halt]. label := compiledMethod attributeAt: #label ifAbsent:[self halt]. Note the absence of the final colon on #subform and #label ! HTH, R - _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Thanks for the help Reinout & Karsten! This should help me with some
code re-use -- Rick On Jan 15, 2009, at 1:25 AM, Reinout Heeck wrote: > >> >> FooBar>>fooGroup1 >> <subform: #foobarbaz> >> <label: 'group #1'> >> ^ self fooValues >> >> > > > compiledMethod := (FooBar findSelector: #fooGroup1) last. > > form := compiledMethod attributeAt: #subform ifAbsent:[self halt]. > label := compiledMethod attributeAt: #label ifAbsent:[self halt]. > > > Note the absence of the final colon on #subform and #label ! > > > HTH, > > R > - > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Rick Flower
On Jan 14, 2009, at 11:01 PM, Richard E. Flower wrote: > Hi all.. > > I've got an odd question but figured I'd ask regardless... I don't think it's an odd question at all. Good question actually. > I'd like to have one method in a class that could have a pragma in it > (see examples below) and I'd like to be able to ask the Pragma class > if method #foo has a particular pragma present in it.. However, all of > the methods in the pragma class look for pragma's across the entire > class.. Is the best way to achieve this to call the existing method > and then review the output to see if the method name matches or is > there a better way..? > > Below is example w/ pragma : > > FooBar>>fooGroup1 > <subform: #foobarbaz> > <label: 'group #1'> > ^ self fooValues > > Ideally I'd like to be able to do something like -- not sure the > syntax makes sense: > > t := (Pragma allNamed: #subform: inMethod: fooGroup inClass: FooBar). There's a Pragma>>allInMethod: aCompiledMethod. That may have been added post 7.6 tho. I think I used it in Asset related stuff. As Karsten pointed out, the "data" for method tags is actually kept on the methods themselves, and can be accessed via the #attributeMessages method. This will return an Array of "Message" objects. The Message objects are just message selectors, and the arguments. Pragma objects are usually more transient, used to reify the existence of a particular attribute message AND the method that it is defined in, in one object. It's to a method tag, what a MethodDefinition is to a CompiledMethod. It's too bad, that we've begun to pollute the class side with lots of queries, all kind of simpler, instead of keeping a smaller set of composable APIs. To get all the Pragmas in a CompiledMethod, you can do: aMethod attributeMessages collect: [:each | Pragma new message: each methodDefinition: aMethod definition]. If you just want to know if aMethod has a given tag in it, you could do something like: aMethod attributeMessages anySatisfy: [:each | each selector = #what:youre:looking:for] I would NOT use the attributeAt:ifAbsent: method. It is an older API, still there for compatibility. It harkens from days gone by when method tags (attributeMessages) were a (synthesized) dictionary which did not preserve order, and only supported unique single arg tags. -- Travis Griggs Objologist "Every institution finally perishes by an excess of its own first principle." - Lord Acton _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Thanks Everyone! Great suggestions by everyone! I tried out the
samples and they work great.. Travis -- I'll avoid the older API since the other ones work just fine! -- Rick On Thu, January 15, 2009 9:58 am, Travis Griggs wrote: > > On Jan 14, 2009, at 11:01 PM, Richard E. Flower wrote: > >> Hi all.. >> >> I've got an odd question but figured I'd ask regardless... > > I don't think it's an odd question at all. Good question actually. > >> I'd like to have one method in a class that could have a pragma in it >> (see examples below) and I'd like to be able to ask the Pragma class >> if method #foo has a particular pragma present in it.. However, all of >> the methods in the pragma class look for pragma's across the entire >> class.. Is the best way to achieve this to call the existing method >> and then review the output to see if the method name matches or is >> there a better way..? >> >> Below is example w/ pragma : >> >> FooBar>>fooGroup1 >> <subform: #foobarbaz> >> <label: 'group #1'> >> ^ self fooValues >> >> Ideally I'd like to be able to do something like -- not sure the >> syntax makes sense: >> >> t := (Pragma allNamed: #subform: inMethod: fooGroup inClass: FooBar). > > There's a Pragma>>allInMethod: aCompiledMethod. That may have been > added post 7.6 tho. I think I used it in Asset related stuff. > > As Karsten pointed out, the "data" for method tags is actually kept on > the methods themselves, and can be accessed via the #attributeMessages > method. This will return an Array of "Message" objects. The Message > objects are just message selectors, and the arguments. Pragma objects > are usually more transient, used to reify the existence of a > particular attribute message AND the method that it is defined in, in > one object. It's to a method tag, what a MethodDefinition is to a > CompiledMethod. It's too bad, that we've begun to pollute the class > side with lots of queries, all kind of simpler, instead of keeping a > smaller set of composable APIs. > > To get all the Pragmas in a CompiledMethod, you can do: > > aMethod attributeMessages collect: [:each | Pragma new message: each > methodDefinition: aMethod definition]. > > If you just want to know if aMethod has a given tag in it, you could > do something like: > > aMethod attributeMessages anySatisfy: [:each | each selector = > #what:youre:looking:for] > > I would NOT use the attributeAt:ifAbsent: method. It is an older API, > still there for compatibility. It harkens from days gone by when > method tags (attributeMessages) were a (synthesized) dictionary which > did not preserve order, and only supported unique single arg tags. > > -- > Travis Griggs > Objologist > "Every institution finally perishes by an excess of its own first > principle." - Lord Acton > > > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > > _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
One more question on this topic if I could.. I've got the logic in place to extract out the subform name and it gets turned into an immutable ByteSymbol that shows up in the debugger as something like #myClass.. However, when I do something like t := (subForm new) I get a DNU because it isn't really working on an name of a class I guess.. I used 'asSymbol' at the end of the code that extracts the subForm from the pragma.. Any ideas how to turn this back into something I can issue a 'new' on? Do I need to use #perform: on it instead or ?? On Jan 15, 2009, at 6:31 PM, Rick Flower wrote: > Thanks Everyone! Great suggestions by everyone! I tried out the > samples and they work great.. > > Travis -- I'll avoid the older API since the other ones work just > fine! > > -- Rick > > On Thu, January 15, 2009 9:58 am, Travis Griggs wrote: >> >> On Jan 14, 2009, at 11:01 PM, Richard E. Flower wrote: >> >>> Hi all.. >>> >>> I've got an odd question but figured I'd ask regardless... >> >> I don't think it's an odd question at all. Good question actually. >> >>> I'd like to have one method in a class that could have a pragma in >>> it >>> (see examples below) and I'd like to be able to ask the Pragma class >>> if method #foo has a particular pragma present in it.. However, >>> all of >>> the methods in the pragma class look for pragma's across the entire >>> class.. Is the best way to achieve this to call the existing method >>> and then review the output to see if the method name matches or is >>> there a better way..? >>> >>> Below is example w/ pragma : >>> >>> FooBar>>fooGroup1 >>> <subform: #foobarbaz> >>> <label: 'group #1'> >>> ^ self fooValues >>> >>> Ideally I'd like to be able to do something like -- not sure the >>> syntax makes sense: >>> >>> t := (Pragma allNamed: #subform: inMethod: fooGroup inClass: >>> FooBar). >> >> There's a Pragma>>allInMethod: aCompiledMethod. That may have been >> added post 7.6 tho. I think I used it in Asset related stuff. >> >> As Karsten pointed out, the "data" for method tags is actually kept >> on >> the methods themselves, and can be accessed via the >> #attributeMessages >> method. This will return an Array of "Message" objects. The Message >> objects are just message selectors, and the arguments. Pragma objects >> are usually more transient, used to reify the existence of a >> particular attribute message AND the method that it is defined in, in >> one object. It's to a method tag, what a MethodDefinition is to a >> CompiledMethod. It's too bad, that we've begun to pollute the class >> side with lots of queries, all kind of simpler, instead of keeping a >> smaller set of composable APIs. >> >> To get all the Pragmas in a CompiledMethod, you can do: >> >> aMethod attributeMessages collect: [:each | Pragma new message: each >> methodDefinition: aMethod definition]. >> >> If you just want to know if aMethod has a given tag in it, you could >> do something like: >> >> aMethod attributeMessages anySatisfy: [:each | each selector = >> #what:youre:looking:for] >> >> I would NOT use the attributeAt:ifAbsent: method. It is an older API, >> still there for compatibility. It harkens from days gone by when >> method tags (attributeMessages) were a (synthesized) dictionary which >> did not preserve order, and only supported unique single arg tags. >> >> -- >> Travis Griggs >> Objologist >> "Every institution finally perishes by an excess of its own first >> principle." - Lord Acton >> >> >> >> _______________________________________________ >> vwnc mailing list >> [hidden email] >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc >> >> > > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Richard,
There are several techniques possible here. I’m not sure how you’re using the pragma arguments. If the subform is just the name of a window spec method, then you could simply say “self class perform: <var>”. Alternatively, this could be the selector of a method that returns the object, in which case “self perform: <var>” would be fine. If the argument to the pragma is supposed to identify the actual class, then you can use the class name or a qualified reference: <subform: #{MyClassQualifiedRef}>. There is no reason you couldn’t use multiple arguments if you needed to: <subform: #{MyClassQualifiedRef} use: ...>.
Cheers!
Tom Hawker -------------------------- Senior Framework Developer -------------------------- Home +1 (408) 274-4128 Office +1 (408) 576-6591 Mobile +1 (408) 835-3643
-----Original Message-----
One more question on this topic if I could.. I've got the logic in place to extract out the subform name and it gets turned into an immutable ByteSymbol that shows up in the debugger as something like #myClass.. However, when I do something like
t := (subForm new)
I get a DNU because it isn't really working on an name of a class I guess.. I used 'asSymbol' at the end of the code that extracts the subForm from the pragma.. Any ideas how to turn this back into something I can issue a 'new' on?
Do I need to use #perform: on it instead or ??
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Thanks Tom! I was in a bit of a hurry and probably ought to look things over.. Currently my pragma just lists the name of the class to instantiate and render (its a Seaside class).. All of this sort of stuff I find very interesting as it's something that can not be done for the most part in my 'daily' languages I use (as far as I know).. Pretty slick stuff! On Fri, January 16, 2009 8:51 am, [hidden email] wrote: > Richard, > > > > There are several techniques possible here. I'm not sure how you're using > the pragma arguments. If the subform is just the name of a window spec > method, then you could simply say "self class perform: <var>". > Alternatively, this could be the selector of a method that returns the > object, in which case "self perform: <var>" would be fine. If the > argument to the pragma is supposed to identify the actual class, then you > can use the class name or a qualified reference: <subform: > #{MyClassQualifiedRef}>. There is no reason you couldn't use multiple > arguments if you needed to: <subform: #{MyClassQualifiedRef} use: ...>. > > > > Cheers! > > > > Tom Hawker > > -------------------------- > > Senior Framework Developer > > -------------------------- > > Home +1 (408) 274-4128 > > Office +1 (408) 576-6591 > > Mobile +1 (408) 835-3643 > > > > > > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] On Behalf > Of Richard E. Flower > Sent: Friday, January 16, 2009 7:38 AM > To: VW NC > Subject: Re: [vwnc] Pragma question > > > > > > One more question on this topic if I could.. I've got the logic in > > place to extract out the > > subform name and it gets turned into an immutable ByteSymbol that > > shows up in the > > debugger as something like #myClass.. However, when I do something like > > > > t := (subForm new) > > > > I get a DNU because it isn't really working on an name of a class I > > guess.. I used > > 'asSymbol' at the end of the code that extracts the subForm from the > > pragma.. > > Any ideas how to turn this back into something I can issue a 'new' on? > > > > Do I need to use #perform: on it instead or ?? > > > > IMPORTANT NOTICE > Email from OOCL is confidential and may be legally privileged. If it is > not intended for you, please delete it immediately unread. The internet > cannot guarantee that this communication is free of viruses, interception > or interference and anyone who communicates with us by email is taken to > accept the risks in doing so. Without limitation, OOCL and its affiliates > accept no liability whatsoever and howsoever arising in connection with > the use of this email. Under no circumstances shall this email constitute > a binding agreement to carry or for provision of carriage services by > OOCL, which is subject to the availability of carrier's equipment and > vessels and the terms and conditions of OOCL's standard bill of lading > which is also available at http://www.oocl.com. > _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Rick Flower
On Jan 16, 2009, at 7:38 AM, Richard E. Flower wrote: > > One more question on this topic if I could.. I've got the logic in > place to extract out the > subform name and it gets turned into an immutable ByteSymbol that > shows up in the > debugger as something like #myClass.. However, when I do something > like > > t := (subForm new) > > I get a DNU because it isn't really working on an name of a class I > guess.. I used > 'asSymbol' at the end of the code that extracts the subForm from the > pragma.. > Any ideas how to turn this back into something I can issue a 'new' on? > > Do I need to use #perform: on it instead or ?? The Message objects that are embedded as annotations/tags/pragmas/ whatever in the Method, are restricted in that any arguments must be literal. This means basic numbers, strings, literal array, symbols, etc. Included in that set of literals are BindingReferences. So you *may* want to put BindingReferences in your tags. For example: myMethod <tag: #{MySeasideThingie}> When your tag/pragma processing stuff runs then, and you fetch this "object", you can send #value to it, to get the class inferred by the binding reference. HTH -- Travis Griggs Objologist "The best way to know you have a mind is to change it" -Judge Pierre Leval _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
On Fri, January 16, 2009 11:27 am, Travis Griggs wrote:
> The Message objects that are embedded as annotations/tags/pragmas/ > whatever in the Method, are restricted in that any arguments must be > literal. This means basic numbers, strings, literal array, symbols, > etc. Included in that set of literals are BindingReferences. So you > *may* want to put BindingReferences in your tags. For example: > > myMethod > <tag: #{MySeasideThingie}> > > When your tag/pragma processing stuff runs then, and you fetch this > "object", you can send #value to it, to get the class inferred by the > binding reference. Thanks Travis/Tom (Tom sent a note off-line).. I believe what I'm using now is something like : myMethod <mytag: #foobar> I guess I'm not really following all of how the internals within the language work yet, but will try your suggestions and I suspect they'll work just fine.. Thanks again! -- Rick _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |