Re: Beginners Digest, Vol 156, Issue 5

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Beginners Digest, Vol 156, Issue 5

Mark Miller
I've gotten some positive results by querying #packageInfo for a class, such as String:

(String packageInfo referenceForMethod: #alike: ofClass: String) category. --> #comparing

The above will give you the method category for #alike: inside of the String class.

packageInfo returns a reference to a PackageInfo instance. The reason it references the class twice in the above example is you can also query for an array of methods (using a different method) for the entire protocol (up the inheritance hierarchy). So, you probably want to filter down to just the methods for your specific class.

PackageInfo also has #actualMethodsDo: which allows you to give it a block to use, so you can do something with all or some (you test for which you want to deal with, in the block. How you do that I leave to you to investigate. :) ) of the methods inside.

What you're going for is MethodReference's, which will allow you to query for their categories, using the method #category.

Hope this helps.

---Mark
[hidden email]

> On January 16, 2020 at 5:00 AM [hidden email] wrote:
>
>
> Send Beginners mailing list submissions to
> [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> or, via email, send a message with subject or body 'help' to
> [hidden email]
>
> You can reach the person managing the list at
> [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Beginners digest..."
>
>
> Today's Topics:
>
>    1. code to retrieve all method categories and methods under a
>       category (tty)
>    2. Re: Squeak Oversight Board Election 2020 (Ron Teitelbaum)
>    3. Re: code to retrieve all method categories and methods under
>       a category (Tim Johnson)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 15 Jan 2020 13:26:53 -0600 (CST)
> From: tty <[hidden email]>
> To: [hidden email]
> Subject: [Newbies] code to retrieve all method categories and methods
> under a category
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=us-ascii
>
> Hi All.
>
> I want to dynamically build a drop-down menu in Seaside based on the
> instance side methods I have in a class.
>
> #MyClass has method categories: "Attributes Links Paragraph....etc"
> Under Method category Links are  methods #testLinkCategory,
> testLinkExternal, testLink....etc.
>
> I have been hunting for over an hour and I see no obvious way to retrieve
> this info (I have found a way to get all the methods, but not the category
> that houses them.
>
>
> The code I have in mind has form:
>
> *categories := categoriesFor: #MyClass.
>
> categories do:[:cat | |methods|
>              methods :=  methodForClass:#MyClass category: cat.
>              methods do:[:m |
>                              "dynamically build my html here"
> ]]l*
>
>
> Any help much appreciated.
>
> thx
>
>
>
> --
> Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 15 Jan 2020 14:59:00 -0500
> From: Ron Teitelbaum <[hidden email]>
> To: The general-purpose Squeak developers list
> <[hidden email]>
> Cc: [hidden email], Squeak Virtual Machine
> Development Discussion <[hidden email]>, "A
> friendly place to get answers to even the most basic questions about
> Squeak." <[hidden email]>
> Subject: Re: [Newbies] Squeak Oversight Board Election 2020
> Message-ID:
> <[hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> HI All,
>
> Thank you again for everyone's participation in this years Squeak Oversight
> Board election.  Edgar thank you for helping encourage people to
> participate!  Feel free to keep that up!
>
> We currently have 5 candidates for 7 board seats.  In the order they
> announced:
>
> Marcel Taeumel
> David T. Lewis
> Tim Rowledge
> Bert Freudenberg
> Craig Latta
>
> Time is running out to announce your candidacy! Please announce soon!
> There are only 5 days left.  You can follow along by visiting this webpage:
> http://wiki.squeak.org/squeak/6636
>
> I will not be available Saturday through Monday morning. If you wait to
> announce this weekend and I don't update the webpage don't panic.  I'll
> make sure to include you before the ballots go out on Monday.  It would be
> better to announce between now and Friday!
>
> Also if your email has changed or you want to get on the voters list please
> let me know!  If you know someone that you would like to see on the board
> please reach out to them and ask them to run!
>
> Thank you!
>
> All the best,
>
> Ron Teitelbaum
>
>
> On Wed, Jan 15, 2020 at 9:21 AM Craig Latta <[hidden email]>
> wrote:
>
> >
> > Hi all--
> >
> >      I'd like to serve on the Squeak Oversight Board in 2020 (wow, it
> > really does feel like Back to the Future now ;). I'm interested in
> > looking back, as we sometimes do, to plan for the 25th anniversary of
> > Squeak in 2021.
> >
> >      I've also been on a wild ride forward and to the side, with Bert's
> > SqueakJS VM and the Caffeine project. They've brought me into contact
> > with many interesting Smalltalk, JavaScript, and livecoding-adjacent
> > technologies and communities. I want to continue hatching strange ideas
> > about them with my fellow board members, and with you.
> >
> >      Once hatched, those ideas want to grow in our collaborative spaces.
> > I've been helping with the board meeting notes for some time, but we
> > haven't publicized them. I'd like to know how you'd like to see them
> > appear on the Squeak project blog, our mailing lists, and in our live
> > systems. Whatever we come up with will need to be done communally (each
> > of us is doing many other things), but I'd like to help us restart here.
> >
> >      Another technical front I've been pushing recently is modularity
> > and team development. I'd like to get some more livecoders connected
> > this year.
> >
> >
> >      thanks again!
> >      Craig
> >
> > ***
> >
> > [|] https://thiscontext.com
> > [|] https://caffeine.js.org
> > [|] https://toplap.org
> >
> > --
> > Craig Latta
> > Black Page Digital
> > Amsterdam :: San Francisco
> > @ccrraaiigg
> >
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20200115/c5492d2c/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 15 Jan 2020 15:51:49 -0600
> From: Tim Johnson <[hidden email]>
> To: "A friendly place to get answers to even the most basic questions
> about Squeak." <[hidden email]>
> Subject: Re: [Newbies] code to retrieve all method categories and
> methods under a category
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=us-ascii
>
> Hi Timothy,
>
> On Jan 15, 2020, at 1:26 PM, tty wrote:
>
> > Hi All.
> >
> > I want to dynamically build a drop-down menu in Seaside based on the
> > instance side methods I have in a class.
>
> Have you looked at the Seaside sample code for the WABrowser?  On some Seaside images it will be registered at tools/classbrowser by default.  I believe it uses a normal Browser as its model, so that's where to go to find out what's actually going on in the background.
>
> > I have been hunting for over an hour and I see no obvious way to retrieve
> > this info (I have found a way to get all the methods, but not the category
> > that houses them.
> >
> > Any help much appreciated.
>
> Have you looked at ClassOrganizer and ClassDescription?
>
> best,
> a Tim
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
> ------------------------------
>
> End of Beginners Digest, Vol 156, Issue 5
> *****************************************
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
tty
Reply | Threaded
Open this post in threaded view
|

Re: Beginners Digest, Vol 156, Issue 5

tty
Hi Mark,

Thank you.


Inspecting:
(WikitextParserFactory packageInfo referenceForMethod: #testTableCaption
ofClass: WikitextParserFactory)

the method symbol is populated but the 'category' is nil.

*squeak/shared/Squeak5.2-18229-64bit.image
Squeak5.2
latest update: #18233
Current Change Set: WikitextParser
Image format 68021 (64 bit)*

cheers.



--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Beginners Digest, Vol 156, Issue 5

Mark Miller
tty wrote

> Hi Mark,
>
> Thank you.
>
>
> Inspecting:
> (WikitextParserFactory packageInfo referenceForMethod: #testTableCaption
> ofClass: WikitextParserFactory)
>
> the method symbol is populated but the 'category' is nil.

Sorry about that. Looking closer at the method list for PackageInfo, I think
it operates in conjunction with Monticello, and perhaps other package
managers. When I tried creating my own class, I got nil when using
#packageInfo.

It turns out the answer may be simpler.

MethodReference has class-side methods for giving you instances of itself,
based on a class, and the method specification you give it. So, you should
be able to do:

(MethodReference class: WikitextParserFactory method: #testTableCaption)
category

I tried this out with a class of my own, and it works. (It also works for
classes such as String.)

As I showed earlier, if a method is categorized, you will get the method's
category back as a symbol. If a method is not categorized, you will get #'as
yet unclassified' as a return value.

---Mark
[hidden email]




--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners