Jump to content

Talk:Programming idiom

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Fubar Obfusco (talk | contribs) at 05:45, 10 December 2009 (Parallel looping / traversal of lists or other structures: new section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconComputing Unassessed
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
???This article has not yet received a rating on Wikipedia's content assessment scale.
???This article has not yet received a rating on the project's importance scale.

I'd like to have a category/list of idioms that would include things like Graceful exit, Schwartzian Transform, and so on. I'll have to think about the scope of that first. Joseph N Hall 02:30, 31 August 2006 (UTC)[reply]

Isn't i++ example of Syntactic sugar, and not really a computer language idiom? 80.216.68.41 (talk) 19:05, 25 November 2008 (UTC)[reply]

Parallel looping / traversal of lists or other structures

One idiom that has to be "written by hand" in many languages is to step over the members of two or more lists (or arrays, trees, etc.) at once.

In Lisp, there are idioms using DO or LOOP which explicitly allow you to move through two structures at once. In C, you can do it with comma-separated steps in a for(;;) expression, but it's unusual and considered obfuscated; the idiomatic thing is probably to write it by hand in a while loop. In Python, you use tuple unpacking and zip for lists, but for any other structure you'd probably do it by hand (or maybe use iterators). And in Haskell you'd probably lift the traversal operation for the data structure into the list monad. --FOo (talk) 05:45, 10 December 2009 (UTC)[reply]