The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Aliasing Classes

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
Aliasing Classes Posted: Nov 13, 2007 6:30 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Aliasing Classes
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Michael Lucas-Smith

Advertisement

Recently someone asked about the class Squeak.Color in Cincom Smalltalk in the latest development builds and was stunned to find that when they browsed to it, they ended up on Graphics.ColorValue.

What's going on here? We've aliased the Squeak.Color value to Graphics.ColorValue. The basic reason for doing this is because the two classes are effectively the same between Squeak and Cincom Smalltalk. The second reason is that Seaside extends Color with various methods. There is a great deal of trickery in the color code used by Scriptaculous and CSSBarGraphs and a few other Seaside libraries - so instead of making Squeak.Color a subclass of Graphics.ColorValue, I chose to alias it instead.

So how do you do that? Well, it turns out it's pretty easy. Click on the namespace you want to add the alias to and add a shared variable, eg: MyNamespace.MyString and sit its initializer to be the class you want it to alias to - in this case Core.String. Initialize the shared variable and you're done.

The tools are aware of this trick, so they'll work correctly, allowing you to subclass it, reference it in #{}'s, so on and so forth. Happy class aliasing!

Read: Aliasing Classes

Topic: Industry Misinterpretations 61: Big Dave, Part II Previous Topic   Next Topic Topic: Functional Javascript 1.0.2

Sponsored Links



Google
  Web Artima.com   

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