The Artima Developer Community
Sponsored Link

Agile Buzz Forum
A Class Of Shared Name(Space)s

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
A Class Of Shared Name(Space)s Posted: Dec 28, 2006 11:47 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: A Class Of Shared Name(Space)s
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've blogged before about some ill-defined notion where the differentiation between classes and namespaces was made less instead of more. Basically, I wanted to be able to define a class as a private class of another class. Classes are namespaces for shares, allowing them to be any type of object BUT declare classes. And having done a couple of the tools, I can attest to the fact that this just makes things harder than they should be.

This evening, I found myself wanting the opposite. I wanted to create a namespace for simple shares and place that namespace inside of a class. I'm not sure what that does to my "namespaces should just be classes" notion. But it's an interesting twist to my struggles with these things.

The intended use was/is for library constants. When you're doing a library interface like that for Cairo, there are a plethora of constants to define different things. In C they would be grouped by typedef'ing an enum. But enum's are not a natural element of Smalltalk. DLLCC provides a model of an enum, but if you have to access lots of these named constants, that's pretty tedious. Furthermore, the cairo interface is pretty good about grouping these constants with a given "object" type.

For example, stroke (or line) cap styles. In C, you'll have long tedius names like CAIRO_LINE_CAP_BUTT, CAIRO_LINE_CAP_ROUND, and CAIRO_LINE_CAP_SQUARE. And there's family after family of these. The code I'd like to be able to write is:

aCairoContext strokeCap: CapStyles.Square
where CapStyles is a member of CairoContext.

Read: A Class Of Shared Name(Space)s

Topic: Smalltalk Daily: 12/22/06 Previous Topic   Next Topic Topic: First incremental release of badjit

Sponsored Links



Google
  Web Artima.com   

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