The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Is your programming style "Closureful"?

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
Is your programming style "Closureful"? Posted: Dec 29, 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: Is your programming style "Closureful"?
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 been porting a fun little demo program from C to Smalltalk lately. It's simple, straightforward, easy to follow. Makes use of some of the GTK libraries and facilities. One thing just amuses me about it though. It's trying very hard to be like one of those "closureful" programs.

In the UI portion of the program, it has some "stuff" that needs to show up in all or port, and the state of which must evolve, that gets passed from function to function. It's a multivariable structure. Typedef'ed as "Closure". These functions take 'void data*' arguments, which they cast as 'Closure*' on the first line. Elsewhere in the same file is a DockInitClosure. The Model of the thing has a bunch of lists of different things, and it has a bunch of enumeration functions which you pass a function pointer, said function will have as it's first argument, and as it's second argument a.... yep, you guessed it: 'void *data'. And each time, there's some sort of "closure" typedef'ed structure to pass context for the enumeration. Things like ObjectConstrainPolygonClosure and FindNearestClosure. How we take do: for granted!

In the end, I don't know whether to be amused and flattered, or grateful, or sympathetic. Block closures are one of the penultimate wonders of Smalltalk. They're so terse and simple and completely powerful. So I could feel sorry that this person had to use this very limited way of emulating closures. Or I could be amused at the flattery "to be like one of those high falutin' closure languages" implied. Or just plain grateful, because it makes the port that much simpler, because the concepts are closer. Maybe a little of all I guess.

Aside: After running this post through Gender Genie, I'm happy to report that this blog post is decidely masculine by a factor of 4:1. Whew.

Read: Is your programming style "Closureful"?

Topic: Now listed at Podcast Alley Previous Topic   Next Topic Topic: Donate to Solar Cookers International

Sponsored Links



Google
  Web Artima.com   

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