The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Slots all the Way Down

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Slots all the Way Down Posted: Nov 30, 2007 6:15 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Slots all the Way Down
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

I just published another version of the NamedSlot package and associated test package. The test package has 16 tests. They're a bit pedantic, but...

Once you have these things, the real temptation is to not just be able to synthesize them, but actually use them. ClassDescription uses a simple array of strings to model instance variables. And then there are a set of methods which can determine the field index from a name, or a name from a field index. So what this next version brings to the table is a couple of things:

  1. There are about 6 methods which reference the instanceVariables slot directly. Ideally, there would only be two, one for a setter and one for a getter. So I overrode the non-ideal ones and fixed them calling instVarNames. Simplified the code actually, because you don't have to check for nil then.
  2. The instVarNames now routes through the localNamedSlots accessor. That method references the slot directly, but has the ability to detect what kind is stored, and synthesize a return value if necessary.
  3. The instanceVariables: selector now creates NamedSlots around the string arguments.
  4. Finally, a method to useNamedSlots and dontUseNamedSlots on ClassDescription. There's utility methods on the NamedSlot class to convert the whole system one way or the other.

And with a few tweaks like this, it all just works. What is actually stored is transparent, the system charges one. You can just have some classes have NamedSlots while others still have Strings. Or all can be converted. Or they all can be converted back. That the system can be kept running and in tact while doing this sort of self surgery is pretty cool IMO. The pedanticism to my tests should be obvious now hopefully.

If you make the conversion, and then inspect ClassDescription, you'll see what I might call a metaslot. Because 'instanceVariables' has become a collection of NamedSlots about NamedSlots.

I've not actually tried loading this thing yet into a clean image, so I can't say how well that works.

Read: Slots all the Way Down

Topic: Understanding the Purpose Previous Topic   Next Topic Topic: What is there to a name?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use