BuddhistCatholicContemplativeEvangelicalGeneral ChristianHinduJewishLatter-day SaintMuslimNew VisionsProgressive Christian
Beliefs
- Buddhist
- Catholic
- Contemplative
- Evangelical
- General Christian
- Hindu
- Jewish
- Latter-day Saint
- More Voices
- Muslim
- New Visions
- Pagan
- Progressive Christian
Topics
- Religion News
- Food and Religion
- Sports and Religion
- Religious Art
- Religious Music and Entertainment
- Religious Events
- History and Religion
- Style and Religion
- Politics and Religion
- Women in Religion
- Recreation Outdoors and Religion
- Business Finance and Religion
- Careers Workplace and Religion
- Education and Religion
- Family Parenting and Religion
- Health Fitness and Religion
- Home and Religion
- Relationships and Religion
- Technology and Religion
- Travel and Religion
Columnists
- Buddhist Columnists
- Business Finance and Religion Columnists
- Careers Workplace and Religion Columnists
- Catholic Columnists
- Contemplative Columnists
- Education and Religion Columnists
- Evangelists Columnists
- Family Parenting and Religion Columnists
- General Christian Columnists
- Health Fitness and Religion Columnists
- Hindu Columnists
- History and Religion Columnists
- Home and Religion Columnists
- Jewish Columnists
- More Voices Columnists
- Latter Day Columnists
- Muslim Columnists
- New Visions Columnists
- Nonreligious Columnists
- Pagan Columnists
- Politics and Religion Columnists
- Progressive Columnists
- Recreation Outdoors and Religion Columnists
- Relationships and Religion Columnists
- Religion News Columnists
- Religious Art Columnists
- Religious Events Columnists
- Religious Music and Entertainment Columnists
- Sports and Religion Columnists
- Style and Religion Columnists
- Technology and Religion Columnists
- Travel and Religion Columnists
- Women in Religion Columnists
Resource Library
- 2026 Calendar
- Library of World Religions
- The 100 Most Holy Places on Earth
- Patheos Answers
- Podcasts
- Videos
- Faith Leaders Database
- Anglican Episcopalian
- Bahai
- Baptist
- Buddhism
- Christianity
- Confucianism
- Eastern Orthodoxy
- Hinduism
- Holiness and Pentecostal
- ISKCON
- Islam
- Judaism
- Lutheran
- Methodist
- The Church of Jesus Christ of Latter-day Saints
- New Age
- Paganism
- Presbytarian and Reformed
- Protestantism
- Religion Behind the Scenes
- Roman Catholic
- Scientology
- Shia Islam
- Sikhism
- Sufism
- Sunni Islam
- Taoism
- Zen
- See all religions
Research Tools
Ad-Free & Subscriber Log-In Subscription Support
Ad-Free & Subscriber Log-In Subscription Support
- Trending:
- Forgiveness
- |
- Marriage
- |
- Consciousness
- |
- Death Penalty
- |
- Election
- |
- Halloween
Cry 'Woof'
-
Series
- Home
- Catholic
- Coding Beyond The Screen, Part I
Coding Beyond The Screen, Part I
Last updated on: November 15, 2014 at 10:34 am by willduquette
Coding Beyond The Screen, Part I 2014-11-15T10:34:01-05:00 willduquette
Patheos Explore the world's faith through different perspectives on religion and spirituality! Patheos has the views of the prevalent religions and spiritualities of the world.
I’m sitting in Portland International waiting for my flight after the end of the Tcl/Tk conference, so it seems an appropriate time to continue my series on software aesthetics. Previously I talked about writing individual procedures, small and large. But what about entire modules—files—of code?
Some modules are simply one utility procedure after another with a header comment at the top. Those are straightforward. More often, though, I prefer to implement a module as an ensemble command: a Tcl command with subcommands. This gives the whole module a single entry point (the module name) and all of the subcommands are clearly and visibly related together.
The standard Tcl dict command is an example of an ensemble command. A dictionary is similar to an array in other languages, but an array that can be indexed on any value. Dictionaries are often used to store records of data:
set rec [dict create]
dict set rec firstname Joe
dict set rec lastname Blow
dict set rec age 42
if {[dict get $rec age] > 18} {
puts "Person is old enough to vote."
}
Here, we use three of the dict command’s subcommands: dict create, dict set, and dict get. (You’re right; I didn’t add color to the code today. My bad.)
There are many ways to implement ensemble commands; my preferred method is to use the Snit package’s snit::type mechanism. Usually, snit::type defines an object type with instances, rather like a class in other languages; but it can also define a singleton object. And since the standard way of representing an object in Tcl is as a command with subcommands, the singleton object is an ensemble.
Here’s an excerpt from Quill’s project module, which is responsible for retrieving the project’s metadata from disk and making it available to other modules:
snit::type project {
pragma -hasinstances no -hastypedestroy no
# meta - Project metadata array for the project
# being managed.
#
# project - The project name
# version - The project version number
# description - The project description
typevariable meta -array {
project ""
version ""
description ""
}
typemethod name {} { return $meta(project) }
typemethod version {} { return $meta(version) }
typemethod description {} { return $meta(description) }
}
I’ve remove most of the comments and most of the code from this listing, because I’m trying to illustrate the concept. This code is contained in project.tcl, and defines a snit::type called project. The type includes a “type variable”, meta, which contains metadata about the project (far more than is shown here). It also defines “type methods”, which are essentially Tcl procedures that define subcommands of the type command. Here we define three type methods, to return the project’s name, version number, and description.
Another module in Quill might use these commands like this:
puts "Building project:"
puts "Name: [project name]"
puts "Version: [project version]"
... code to build the project ...
Next time, I’ll talk about the structure of a singleton module.
____
photo credit: campra via photopin cc
Previous Post

November 14, 2014
Portland, O Portland
Next Post

November 17, 2014 Catching up....
Browse Our Archives
Select a Category Admin App o' the Morning Ask the Dogmat Believing Thomas Bits of Fiction Blasts from the Past Bootstrapping the Interior Life Catholic Mom Christian Living Deep Thoughts from the Doghouse Dominicana Evangelii Gaudium Interviews It Was A Dark and Stormy Night Links to This and That Lumen Fidei Meme Watch On Writing Operation Gratitude Pedant Errant Photography Quill Random Barkings S'Mary's World Shakers of Salt Software Development The Dog Whistler The Dogmat Sez Third Orders Thomas Aquinas Uncategorized Vikings at Dinos Woof Guide to Cinema Woof Guide to History Woof Guide to Literature Woof Guide to Obscure Catholic Music Woof Guide to Philosophy Woof Guide to Popular Music Woof Guide to Technology Woof Guide to Theology Words I Wish I'd Written Works For Me
Select a Month September 2016 August 2016 June 2016 May 2016 April 2016 March 2016 February 2016 January 2016 December 2015 November 2015 October 2015 September 2015 August 2015 July 2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 December 2013 November 2013 October 2013
Follow Us!
TAKE THE
Religious Wisdom Quiz
What does "Shema" mean in Hebrew?
Select your answer to see how you score.
Wait Obey Pray Hear
Related posts from Cry 'Woof'
Beautiful Code One Screen at a Time, Part...
TRENDING AT PATHEOS Catholic
Rejecting Doom: Christian Hope And Human Action
Christianity is a religion of hope. We are to have hope and...
It’s What Comes From Within Which Matters
One of the most difficult things for us to understand is why...
Why I Choose the Eucharist Over the Sermon
Choose the Eucharist, Not the Sermon What are we supposed to get...
5 Design Elements Found in Spiritually Rooted Homes
Putting Spirituality Into Home Decor Our homes are more than our living...
Credo: A Story of God Told with the...
About 10 years ago, I began to imagine a personal "Credo" that...
The Anatomy of Divine Revelation in Catholic Thought
The claim that God has made Himself known to human beings is...
view all Catholic blogs
Ad-Free & Subscriber Log-In Subscription Support
- About Us
- 2026 Calendar
- Videos
- Podcasts
- Library of World Religions
- Faith In Media Tracker
- Advertise With Us
- Write for Us
- Privacy Policy
- Terms of Service
- Do Not Sell My Data
- Contact Us
- Radiant Digital
- Manage Newsletter Subscriptions
- Unsubscribe From Notifications
- Sitemap
Copyright 2008-2026, Patheos. All rights reserved.
Subscription Support Ad-Free & Subscriber Log-In






