<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8397311766319215218</id><updated>2010-04-22T19:31:51.901-07:00</updated><title type='text'>metablog</title><subtitle type='html'></subtitle><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default?start-index=26&amp;max-results=25'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.metaobject.com/blog/atom.xml'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>31</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-2472086524060473832</id><published>2010-04-22T19:31:00.001-07:00</published><updated>2010-04-22T19:31:52.075-07:00</updated><title type='text'>This blog has moved</title><content type='html'>
       This blog is now located at http://metaoblog.blogspot.com/.
       You will be automatically redirected in 30 seconds, or you may click &lt;a href='http://metaoblog.blogspot.com/'&gt;here&lt;/a&gt;.

       For feed subscribers, please update your feed subscriptions to
       http://metaoblog.blogspot.com/feeds/posts/default.
  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-2472086524060473832?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/2472086524060473832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=2472086524060473832' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/2472086524060473832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/2472086524060473832'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2010/04/this-blog-has-moved.html' title='This blog has moved'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-7606244019279706390</id><published>2010-01-24T15:54:00.001-08:00</published><updated>2010-03-06T16:35:49.358-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Objective-XML 5.3</title><content type='html'>New in this release:&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.cocotron.org/"&gt;Cocotron&lt;/a&gt; targets for Windows support.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.xmlrpc.com/"&gt;XMLRPC&lt;/a&gt; support.&lt;/li&gt;
&lt;li&gt;No longer uses 'private' API that was causing AppStore rejections for some iPhone apps using Objective-XML.&lt;/li&gt;
&lt;li&gt;Support for numeric entitites.&lt;/li&gt;

&lt;/ul&gt;
&lt;a href="http://www.metaobject.com/downloads/Objective-C/Objective-XML-5.3.tgz"&gt;http://www.metaobject.com/downloads/Objective-C/Objective-XML-5.3.tgz&lt;/a&gt;.
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-7606244019279706390?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/7606244019279706390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=7606244019279706390' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/7606244019279706390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/7606244019279706390'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2010/01/objective-xml-53.html' title='Objective-XML 5.3'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-130262743736304653</id><published>2009-12-13T13:05:00.001-08:00</published><updated>2009-12-13T13:38:45.627-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Higher Order Messaging'/><category scheme='http://www.blogger.com/atom/ns#' term='Cocoa'/><title type='text'>The Responder Chain is a Collection</title><content type='html'>Timothy Wood voices some great ideas on &lt;a href="http://www.cocoatoa.com/posts/2009/12/08/modernizing_the_responder_chain/"&gt;modernizing the Cocoa responder chain&lt;/a&gt;.   

I'd like to venture that if we treat the &lt;a href="http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html"&gt;Responder Chain&lt;/a&gt; as a simple collection, a singly-linked list, then such alternatives become easier to model and reason about.&lt;p&gt; 
&lt;hr&gt;
&lt;pre&gt;
NSEnumerator *responderEnumerator = [[firstResponder mapToNextObjectFromMessage] nextResponder];
&lt;/pre&gt;
&lt;hr&gt;
I am currently abstracting from the intricate delegate mapping and other ops, these could be handled in an analog fashion.
With the enumerator in place, we can obviously snapshot it to get the current state of the responder chain, and also log that.
&lt;hr&gt;
&lt;pre&gt;
NSArray *responders = [responderEnumerator allObjects];
NSLog(@"full responder chain:  %@",responders);
&lt;/pre&gt;
&lt;hr&gt;

Now we can express both current features and possible variations of the Responder Chain architecture compactly as common collection operations.  The current dispatch mechanism simply sends the message to the first object that is capable of responding.  This corresponds to using the first object of a &lt;em&gt;-select&lt;/em&gt;, which is expressed in the -selectFirst convenience method.

&lt;hr&gt;
&lt;h4&gt;Current dispatch&lt;/h4&gt; 
&lt;pre&gt;
[[[responders selectFirst] respondsToSelector:action] performSelector:action withObject:sender];

&lt;/pre&gt;
&lt;hr&gt;

If I understood him correctly, Tim wants the objects in the responder chain to return an object that they would like to respond to the message.  This turns the &lt;em&gt;-select&lt;/em&gt; into a &lt;em&gt;-collect&lt;/em&gt; (without a &lt;em&gt;-collectFirst&lt;/em&gt;), but is otherwise very similar.

&lt;hr&gt;
&lt;h4&gt;Tim's dispatch&lt;/h4&gt; 
&lt;pre&gt;
possibleResponders = [[responders collect] responsibleTargetForAction:theAction sender:sender]];
[[possibleResponders objectAtIndex:0] performSelector:action withObject:sender];
&lt;/pre&gt;
&lt;hr&gt;
I hope this does Tim's ideas justice, but I think the succinct formulation should make it easy to tell wether it does or not.&lt;p&gt;
In terms of combining validation with target/action, I'd be somewhat
wary of accidentally triggering actions when validation was meant, though I do appreciate the advantages of combining the two operations.
I am not sure what value the block is adding over just having an additional BOOL parameter in the target/action method.&lt;hr&gt;
&lt;h4&gt;Combined action and validation&lt;/h4&gt; 
&lt;pre&gt;
typedef BOOL IBAction;
-(IBAction)delete:sender  :(BOOL)onlyValidate
{
    NSArray *selection = [self selectedItems];

   if ( onlyValidate || [selection count] == 0 ) {
        return NO;
   }
   // perform the action
}
// or if you're worried about the naming issues
-(IBAction)delete:sender
{
}
&lt;/pre&gt;
&lt;hr&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-130262743736304653?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/130262743736304653/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=130262743736304653' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/130262743736304653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/130262743736304653'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/12/responder-chain-is-collection.html' title='The Responder Chain is a Collection'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-6769487009675904692</id><published>2009-12-09T08:38:00.001-08:00</published><updated>2009-12-09T08:38:52.656-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='Cocoa'/><title type='text'>Simple Objective-XML example</title><content type='html'>&lt;html&gt;
&lt;head&gt;

  &lt;style type="text/css"&gt;
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Menlo}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Menlo; color: #3f1c7e}
    p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Menlo; color: #da2e24}
    p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Menlo; color: #c22a9f}
    p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Menlo; color: #743ca6}
    p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Menlo; color: #008419}
    span.s1 {color: #c22a9f}
    span.s2 {color: #743ca6}
    span.s3 {color: #000000}
    span.s4 {color: #da2e24}
    span.s5 {color: #3f1c7e}
    span.s6 {color: #7c492e}
    span.s7 {color: #2b595d}
    span.Apple-tab-span {white-space:pre}
  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

Many times now, I've been asked about more Objective-XML examples.  Here's a very simple one.  It is adapted from Marcus Zarra's very helpful &lt;a href="http://www.cimgf.com/2008/08/18/cocoa-tutorial-libxml-and-xmlreader/"&gt;libxml and xmlreader tutorial&lt;/a&gt;.  That tutorial shows how to parse a very simple XML format using libxml2.&lt;p&gt;

The XML file parsed is the following:

&lt;blockquote&gt;
&lt;p class="p3"&gt;&amp;lt;?xml version=&lt;span class="s1"&gt;"1.0"&lt;/span&gt; encoding=&lt;span class="s1"&gt;"UTF-8"&lt;/span&gt;?&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&amp;lt;root&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;  &lt;/span&gt;&lt;/span&gt;&amp;lt;person&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;    &lt;/span&gt;&lt;/span&gt;&amp;lt;name&amp;gt;&lt;span class="s2"&gt;John Doe&lt;/span&gt;&amp;lt;/name&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;    &lt;/span&gt;&lt;/span&gt;&amp;lt;age&amp;gt;&lt;span class="s2"&gt;14&lt;/span&gt;&amp;lt;/age&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;  &lt;/span&gt;&lt;/span&gt;&amp;lt;/person&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;  &lt;/span&gt;&lt;/span&gt;&amp;lt;person&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;    &lt;/span&gt;&lt;/span&gt;&amp;lt;name&amp;gt;&lt;span class="s2"&gt;Mary Doe&lt;/span&gt;&amp;lt;/name&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;    &lt;/span&gt;&lt;/span&gt;&amp;lt;age&amp;gt;&lt;span class="s2"&gt;14&lt;/span&gt;&amp;lt;/age&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;  &lt;/span&gt;&lt;/span&gt;&amp;lt;/person&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;  &lt;/span&gt;&lt;/span&gt;&amp;lt;person&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;    &lt;/span&gt;&lt;/span&gt;&amp;lt;name&amp;gt;&lt;span class="s2"&gt;John Smith&lt;/span&gt;&amp;lt;/name&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;    &lt;/span&gt;&lt;/span&gt;&amp;lt;age&amp;gt;&lt;span class="s2"&gt;15&lt;/span&gt;&amp;lt;/age&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s2"&gt;&lt;span class="Apple-converted-space"&gt;  &lt;/span&gt;&lt;/span&gt;&amp;lt;/person&amp;gt;&lt;/p&gt;
&lt;p class="p3"&gt;&amp;lt;/root&amp;gt;&lt;/p&gt;


&lt;/blockquote&gt;

It is parsed using at application startup using the following code:

&lt;blockquote&gt;
&lt;p class="p1"&gt;- (&lt;span class="s1"&gt;void&lt;/span&gt;)applicationDidFinishLaunching:(&lt;span class="s2"&gt;NSNotification&lt;/span&gt;*)notification&lt;/p&gt;
&lt;p class="p1"&gt;{&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="s2"&gt;NSString&lt;/span&gt;&lt;span class="s3"&gt; *path = [[&lt;/span&gt;&lt;span class="s2"&gt;NSBundle&lt;/span&gt;&lt;span class="s3"&gt; &lt;/span&gt;mainBundle&lt;span class="s3"&gt;] &lt;/span&gt;pathForResource&lt;span class="s3"&gt;:&lt;/span&gt;&lt;span class="s4"&gt;@"xmlExample"&lt;/span&gt;&lt;span class="s3"&gt; &lt;/span&gt;ofType&lt;span class="s3"&gt;:&lt;/span&gt;&lt;span class="s4"&gt;@"xml"&lt;/span&gt;&lt;span class="s3"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s2"&gt;NSData&lt;/span&gt; *xmlData = [&lt;span class="s2"&gt;NSData&lt;/span&gt; &lt;span class="s5"&gt;dataWithContentsOfFile&lt;/span&gt;:path];&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s2"&gt;xmlTextReaderPtr&lt;/span&gt; reader = &lt;span class="s5"&gt;xmlReaderForMemory&lt;/span&gt;([xmlData &lt;span class="s5"&gt;bytes&lt;/span&gt;],&lt;/p&gt;
&lt;p class="p1"&gt;&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;[xmlData &lt;span class="s5"&gt;length&lt;/span&gt;],&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;[path &lt;span class="s5"&gt;UTF8String&lt;/span&gt;], &lt;span class="s1"&gt;nil&lt;/span&gt;,&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;(&lt;/span&gt;XML_PARSE_NOBLANKS&lt;span class="s3"&gt; | &lt;/span&gt;XML_PARSE_NOCDATA&lt;span class="s3"&gt; | &lt;/span&gt;XML_PARSE_NOERROR&lt;span class="s3"&gt; | &lt;/span&gt;XML_PARSE_NOWARNING&lt;span class="s3"&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s1"&gt;if&lt;/span&gt; (!reader) {&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="s5"&gt;NSLog&lt;/span&gt;&lt;span class="s3"&gt;(&lt;/span&gt;@"Failed to load xmlreader"&lt;span class="s3"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="p4"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;return&lt;span class="s3"&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;}&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s2"&gt;NSString&lt;/span&gt; *currentTagName = &lt;span class="s1"&gt;nil&lt;/span&gt;;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s2"&gt;NSDictionary&lt;/span&gt; *currentPerson = &lt;span class="s1"&gt;nil&lt;/span&gt;;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s2"&gt;NSString&lt;/span&gt; *currentTagValue = &lt;span class="s1"&gt;nil&lt;/span&gt;;&lt;/p&gt;
&lt;p class="p5"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;NSMutableArray&lt;span class="s3"&gt; *people = [&lt;/span&gt;NSMutableArray&lt;span class="s3"&gt; &lt;/span&gt;&lt;span class="s5"&gt;array&lt;/span&gt;&lt;span class="s3"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s1"&gt;char&lt;/span&gt;* temp;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s1"&gt;while&lt;/span&gt; (&lt;span class="s6"&gt;true&lt;/span&gt;) {&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="s1"&gt;if&lt;/span&gt;&lt;span class="s3"&gt; (!&lt;/span&gt;xmlTextReaderRead&lt;span class="s3"&gt;(reader)) &lt;/span&gt;&lt;span class="s1"&gt;break&lt;/span&gt;&lt;span class="s3"&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="s1"&gt;switch&lt;/span&gt;&lt;span class="s3"&gt; (&lt;/span&gt;xmlTextReaderNodeType&lt;span class="s3"&gt;(reader)) {&lt;/span&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="s1"&gt;case&lt;/span&gt;&lt;span class="s3"&gt; &lt;/span&gt;XML_READER_TYPE_ELEMENT&lt;span class="s3"&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p class="p6"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;//We are starting an element&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;temp =&lt;span class="Apple-converted-space"&gt;  &lt;/span&gt;(&lt;span class="s1"&gt;char&lt;/span&gt;*)&lt;span class="s5"&gt;xmlTextReaderConstName&lt;/span&gt;(reader);&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;currentTagName = [&lt;span class="s2"&gt;NSString&lt;/span&gt; &lt;span class="s5"&gt;stringWithCString&lt;/span&gt;:temp&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;encoding&lt;span class="s3"&gt;:&lt;/span&gt;NSUTF8StringEncoding&lt;span class="s3"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s1"&gt;if&lt;/span&gt; ([currentTagName &lt;span class="s5"&gt;isEqualToString&lt;/span&gt;:&lt;span class="s4"&gt;@"person"&lt;/span&gt;]) {&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;currentPerson = [&lt;span class="s2"&gt;NSMutableDictionary&lt;/span&gt; &lt;span class="s5"&gt;dictionary&lt;/span&gt;];&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;[people &lt;span class="s5"&gt;addObject&lt;/span&gt;:currentPerson];&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;}&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/p&gt;
&lt;p class="p4"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;continue&lt;span class="s3"&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="s1"&gt;case&lt;/span&gt;&lt;span class="s3"&gt; &lt;/span&gt;XML_READER_TYPE_TEXT&lt;span class="s3"&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p class="p6"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;//The current tag has a text value, stick it into the current person&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;temp = (&lt;span class="s1"&gt;char&lt;/span&gt;*)&lt;span class="s5"&gt;xmlTextReaderConstValue&lt;/span&gt;(reader);&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;currentTagValue = [&lt;span class="s2"&gt;NSString&lt;/span&gt; &lt;span class="s5"&gt;stringWithCString&lt;/span&gt;:temp&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;encoding&lt;span class="s3"&gt;:&lt;/span&gt;NSUTF8StringEncoding&lt;span class="s3"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="s1"&gt;if&lt;/span&gt; (!currentPerson) &lt;span class="s1"&gt;return&lt;/span&gt;;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;[currentPerson &lt;span class="s5"&gt;setValue&lt;/span&gt;:currentTagValue &lt;span class="s5"&gt;forKey&lt;/span&gt;:currentTagName];&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;currentTagValue = &lt;span class="s1"&gt;nil&lt;/span&gt;;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;currentTagName = &lt;span class="s1"&gt;nil&lt;/span&gt;;&lt;/p&gt;
&lt;p class="p4"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;default&lt;span class="s3"&gt;: &lt;/span&gt;continue&lt;span class="s3"&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;}&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;}&lt;/p&gt;
&lt;p class="p3"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="s5"&gt;NSLog&lt;/span&gt;&lt;span class="s3"&gt;(&lt;/span&gt;@"%@:%s Final data: %@"&lt;span class="s3"&gt;, [&lt;/span&gt;&lt;span class="s1"&gt;self&lt;/span&gt;&lt;span class="s3"&gt; &lt;/span&gt;&lt;span class="s5"&gt;class&lt;/span&gt;&lt;span class="s3"&gt;], &lt;/span&gt;&lt;span class="s1"&gt;_cmd&lt;/span&gt;&lt;span class="s3"&gt;, people);&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;[&lt;span class="s1"&gt;self&lt;/span&gt; &lt;span class="s7"&gt;setRecords&lt;/span&gt;:people];&lt;/p&gt;
&lt;p class="p1"&gt;}&lt;/p&gt;

&lt;/blockquote&gt;

To parse it using MAX you need to add MPWXmlKit and MPWFoundation to your project, and then replace the code above with the following:

&lt;blockquote&gt;

&lt;p class="p1"&gt;- (&lt;span class="s1"&gt;void&lt;/span&gt;)applicationDidFinishLaunching:(&lt;span class="s2"&gt;NSNotification&lt;/span&gt;*)notification&lt;/p&gt;
&lt;p class="p1"&gt;{&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="s2"&gt;NSString&lt;/span&gt;&lt;span class="s3"&gt; *path = [[&lt;/span&gt;&lt;span class="s2"&gt;NSBundle&lt;/span&gt;&lt;span class="s3"&gt; &lt;/span&gt;mainBundle&lt;span class="s3"&gt;] &lt;/span&gt;pathForResource&lt;span class="s3"&gt;:&lt;/span&gt;&lt;span class="s4"&gt;@"xmlExample"&lt;/span&gt;&lt;span class="s3"&gt; &lt;/span&gt;ofType&lt;span class="s3"&gt;:&lt;/span&gt;&lt;span class="s4"&gt;@"xml"&lt;/span&gt;&lt;span class="s3"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p2"&gt;&lt;span class="s3"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="s2"&gt;NSArray&lt;/span&gt;&lt;span class="s3"&gt; *people=[[&lt;/span&gt;&lt;span class="s2"&gt;MPWMAXParser&lt;/span&gt;&lt;span class="s3"&gt; &lt;/span&gt;parser&lt;span class="s3"&gt;] &lt;/span&gt;parsedDataFromURL&lt;span class="s3"&gt;:[&lt;/span&gt;&lt;span class="s2"&gt;NSURL&lt;/span&gt;&lt;span class="s3"&gt; &lt;/span&gt;fileURLWithPath&lt;span class="s3"&gt;:path]];&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="Apple-tab-span"&gt;	&lt;/span&gt;[&lt;span class="s1"&gt;self&lt;/span&gt; &lt;span class="s5"&gt;setRecords&lt;/span&gt;:people];&lt;/p&gt;
&lt;p class="p1"&gt;}&lt;/p&gt;

&lt;/blockquote&gt;

&lt;/body&gt;

&lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-6769487009675904692?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/6769487009675904692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=6769487009675904692' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/6769487009675904692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/6769487009675904692'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/12/simple-objective-xml-example.html' title='Simple Objective-XML example'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-2839549565849301289</id><published>2009-12-09T02:54:00.001-08:00</published><updated>2009-12-09T06:03:23.106-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Testing'/><title type='text'>Some test-driven-development notes</title><content type='html'>A couple of random points that might be of interest:

&lt;h4&gt;Code coverage tools&lt;/h4&gt;


&lt;pre&gt;
  if ( rare-condition ) {
      -is this code tested?-
  }
&lt;/pre&gt;

If you actually followed test-first, then the code in the rare if is definitely tested, because if there isn't failing test case for the rare condition, then there is no reason for the code or the test to exist.&lt;p&gt;

Another objection could be that people won't follow the techniques.  I haven't found this to be a big or recurring practical problem so far,
and agile techniqes tend to be empirically driven.  If you suspect that this is a problem you are seeing in your environment, running a code-coverage tool to put some data behind your suspicion may be a good idea.&lt;p&gt;

&lt;h4&gt;Test before or test after?&lt;/h4&gt;

Note that the solution to the code-coverage question above does not
work if tests are written after the fact:  in this case, the rare-case is likely &lt;em&gt;not&lt;/em&gt; to be covered because it was written without being forced by a failing unit test.&lt;p&gt;

Many if not most of the benefits of TDD are related to the way they shape the
design of the code, all of these benefits obviously don't accrue
if you've already designed or even written the code.  In fact, if you ask the XP
folks about it, they will tell you that TDD is not for ensuring
quality, it is exclusively for helping with coding and design.&lt;p&gt;


For example, figuring out
how to test something will force you to come to a clarity about
what the code is supposed to do that just writing the code usually
does not.&lt;p&gt;

Knowing that your tests cover your code (see above) allows you to do extremely
radical refactorings at any point in the development process.  The
ability to refactor at any time in turn allows you to keep your
initial designs simple without coding for anticipated changes.  Not
coding for anticipated changes that may not occur or may occur
differently than you expect in turns allows you to move more quickly,
which more than pays for the expense of the tests.&lt;p&gt;

Furthermore, the tests force you to think how you can call the
functionality you are about to implement, which means it shapes
architecture towards simplicity, high cohesion and low-coupling.&lt;p&gt;

&lt;h4&gt;Generating tests&lt;/h4&gt;

Auto-generating tests for existing methods is a means of subverting the test-driven approach:  there will be the appearance of testing, but with
virtually none of the benefits.  It is probably worse than not having
tests, because in the latter case you at least know that you're not
covered.&lt;p&gt;

Is it a good way of starting with unit test coverage for legacy code?  No.  See the &lt;a href="http://c2.com/cgi/wiki?RefactoringLegacyCode"&gt;C2 wiki entry&lt;/a&gt; for a good explanation of how to approach this case.  In short, start refactoring and adding unit tests when you actually need to touch the code, 
be it for new features or to fix defects that are scheduled to be fixed.&lt;p&gt;



&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-2839549565849301289?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/2839549565849301289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=2839549565849301289' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/2839549565849301289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/2839549565849301289'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/12/some-test-driven-development-notes.html' title='Some test-driven-development notes'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-9046487851133964083</id><published>2009-11-10T00:25:00.001-08:00</published><updated>2009-11-10T00:25:25.035-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Higher Order Messaging'/><category scheme='http://www.blogger.com/atom/ns#' term='Blocks'/><category scheme='http://www.blogger.com/atom/ns#' term='Smalltalk'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><category scheme='http://www.blogger.com/atom/ns#' term='Cocoa'/><title type='text'>Blocked-C II</title><content type='html'>&lt;a href="http://people.untyped.org/damien.pollet/"&gt;Damien Pollet&lt;/a&gt; thinks my &lt;a href="http://www.metaobject.com/blog/2009/11/blocked-c.html"&gt;comparison between Objective-C blocks and HOM&lt;/a&gt; is not completely fair:
&lt;blockquote&gt;
… from my (Smalltalk) experience, the block passed to #collect: is often not a single message send, but rather a small adhoc expression, for which it does not really make sense to define a named method. Or you might need both the element and its key/index… how does HOM deal with that?
&lt;/blockquote&gt;
These are certainly valid observations, and were some of the reasons
that I didn't really think that much of HOM for the first couple of
years after coming up with it back in 1997 or so.  Since then, I've
become less and less convinced that the problems raised are a big concern, for a number of reasons.&lt;p&gt;
&lt;h4&gt;Inline vs. Named&lt;/h4&gt;
One reason is that I actually looked at usage of blocks in the Squeak
image, and found that the majority of blocks with at least one argument
(so not ifTrue:, whileTrue: and other control structures) actually did
contain just a single message send, and so could be immediately expressed
as HOMs.  Second, I noticed that there were a lot of fairly large (3+ LOC)
blocks that &lt;em&gt;should&lt;/em&gt; have been separate methods but weren't.
That's when I discovered that the presence of blocks actually 
encourages bad code, and the 'limitation' of HOMs actually was
encouraging better(-factored) code.&lt;p&gt;
Of course, I wasn't particularly convinced by that line of reasoning,
because it smelled too much like "that's not a bug, that's a feature".
Until that is, I saw &lt;a href="http://nat.truemesh.com/"&gt;others&lt;/a&gt; with less vested interest reporting the same
&lt;a href="http://nat.truemesh.com/archives/000535.html"&gt;observation&lt;/a&gt;:

&lt;blockquote&gt;
But are these really limitations? After using higher order messages for a while I've come to think that they are not. The first limitation encourages you move logic that belongs to an object into that object's implementation instead of in the implementation of methods of other objects. The second limitation encourages you to represent application concepts as objects rather than procedural code. Both limitations have the surprising effect of guiding the code away from a procedural style towards better object-oriented design.
&lt;/blockquote&gt;

My experience has been that Nat is right, having a mechanism that
pushes you towards factoring and naming is better for your code
that one that pushes you towards inlining and anonymizing.&lt;p&gt;

&lt;h4&gt;Objective-C I&lt;/h4&gt;

In fact, the Cocoa &lt;a href="http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/Blocks/Articles/bxGettingStarted.html"&gt;example&lt;/a&gt; that Apple gives for blocks illustrates this idea
very well.  They implement a "Finder like" sorting mechanism using blocks:

&lt;blockquote&gt;
&lt;hr&gt;
&lt;pre&gt;
static NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch | NSNumericSearch |
        NSWidthInsensitiveSearch | NSForcedOrderingSearch;
NSLocale *currentLocale = [NSLocale currentLocale];
 
NSComparator finderSort = ^(id string1, id string2) {
    NSRange string1Range = NSMakeRange(0, [string1 length]);
    return [string1 compare:string2 options:comparisonOptions range:string1Range locale:currentLocale];
};
 
NSLog(@"finderSort: %@", [stringsArray sortedArrayUsingComparator:finderSort]);
&lt;/pre&gt;
&lt;hr&gt;
&lt;/blockquote&gt;
The block syntax is so verbose that there is no hope of actually defining the block inline, the supposed raison d'etre for blocks.  So we actually need to take the
block out-of-line and name it.  So it looks suspiciously like an
equivalent implementation using functions:
&lt;blockquote&gt;
&lt;hr&gt;
&lt;pre&gt;
static NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch | NSNumericSearch |
        NSWidthInsensitiveSearch | NSForcedOrderingSearch;
NSLocale *currentLocale = [NSLocale currentLocale];
 
static NSComparisonResult finderSort(id string1, id string2) {
    NSRange string1Range = NSMakeRange(0, [string1 length]);
    return [string1 compare:string2 options:comparisonOptions range:string1Range locale:currentLocale];
};
 
NSLog(@"finderSort: %@", [stringsArray sortedArrayUsingFunction:finderSort context:nil hint:nil]);
&lt;/pre&gt;
&lt;hr&gt;
&lt;/blockquote&gt;
Of course, something as useful as a Finder-like comparison sort
really deserves to be exposed and made available for reuse, rather
than hidden inside one specific sort.  Objective-C categories are
just the mechanism for this sort of thing:
&lt;blockquote&gt;
&lt;hr&gt;
&lt;pre&gt;
@implementation NSString(finderCompare)
-(NSSComparisonResult)finderCompare:(NSString*)string2) {
    NSRange myRange = NSMakeRange(0, [self length]);
    return [self compare:string2 options: NSCaseInsensitiveSearch | NSNumericSearch |
        NSWidthInsensitiveSearch | NSForcedOrderingSearch range:string1Range locale:[NSLocale currentLocale]];
}
@end
NSLog(@"finderSort: %@", [stringsArray sortedArrayUsingSelector:@selector(finderCompare:)]);
&lt;/pre&gt;
&lt;hr&gt;
&lt;/blockquote&gt;
Note that some of these criticisms are specific to Apple's implementation of blocks, they do not apply in the same way to
Smalltalk blocks, which are a lot less noisy.

&lt;h4&gt;Objective-C II&lt;/h4&gt;

Objective-C has at least one other pertinent difference from
Smalltalk, which is that it already contains control structures
in the basic language, without blocks.  (Of course, those control
structures can also take blocks as arguments, but these are the
different types of blocks that are delimited by curly braces and
cannot be passed around as first class objects).&lt;p&gt;

This means that in Objective-C, we already have the ability to
do all the iterating we need, mechanisms such as blocks and 
HOM are mostly conveniences, not required building blocks.  If
we need indices, use a for loop.  If we require keys, use a
key-enumerator and iterate over that.&lt;p&gt;

In fact, I remember when my then colleagues started working
with a enum-filters, a HOM-precursor that's strikingly similar
to the Google Toolbox's &lt;a href="http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/GTMNSEnumerator%2BFilter.m"&gt;GTMSEnumerator+Filter.m&lt;/a&gt;.  They really took to
the elegance, but then also wanted to use it for various special
cases.  They laughed when they realized that those special-cases
were actually already handled better by existing C control structures
such as for-loops.


&lt;h4&gt;FP, HANDs and Aggregate Operations&lt;/h4&gt;
While my dislike of blocks is easy to discount by the usual
inventor's pride (your child must be ugly for mine to be pretty),
that interpretation actually reverses the  causation:  I came 
up with HOM because I was never very fond of blocks.  In fact,
when I first encountered Smalltalk during my university
years I was enthralled until I saw the iteration methods.&lt;p&gt;

That's not to say that do:, collect: and friends were not light-years
ahead of Algol-type control structures, they most definitely were
and still are.  Having some sort of higher-order mechanism is
vastly superior than not having a higher-order mechanism.
I do wish that "higher order mechanism" and "blocks" weren't
used as synonyms quite as much, because they are not, in fact,
synonymous.&lt;p&gt;

When I first encountered  Smalltalk blocks, I had just previously been
exposed to Backus's &lt;a href="http://www.stanford.edu/class/cs242/readings/backus.pdf"&gt;FP&lt;/a&gt;, and that was just so much prettier!  In
FP functions are composed using functionals without ever talking
about actual data, and certainly without talking about individual
elements.  I have always been on the lookout for higher levels
of expression, and this was such a higher level.  Now taking
things down to "here's another element, what do you want to
do with that" was definitely a step back, and quite frankly
a bit of a let-down.&lt;p&gt;

The fundamental difference I see is that in Smalltalk there
is still an iteration, even if it is encapsulated:  we iterate
over some collection and then execute some code for each element.
In FP, and in HOM, there is instead an aggregate operation:  we
take an existing operation and lift it up as applying to an entire collection.&lt;p&gt;

This difference might seem contrived, but the research done with
the &lt;a href="http://www.cs.cmu.edu/~pane/research.html"&gt;HANDS system&lt;/a&gt; demonstrates that it is very real:
&lt;blockquote&gt;
After creating HANDS, I conducted another user study to examine the effectiveness of three features of HANDS: queries, aggregate operations, and data visibility. HANDS was compared with a limited version that lacked these features. In the limited version, programmers were able to achieve the desired results but had to use more traditional programming techniques. Children using the full-featured HANDS system performed significantly better than their peers who used the limited version.
&lt;/blockquote&gt;

I also find this difference to be very real.&lt;p&gt;

The difference between iterating with blocks and lifting operations
to be aggregate operations also shows up in the fact that the lifting can be done on any 
combination of the involved parameters, whereas you tend to only
iterate over one collection at a time, because the collection and
the iteration are in focus.

&lt;h4&gt;Symmetry&lt;/h4&gt;

Finally, the comparison to functional languages shows a couple of 
interesting asymmetries:  in a functional language, higher order
functions can be applied both to named functions and to anonymous
functions.  In essence, the higher order mechanism just takes 
functions and doesn't care wether they are named or not.  Also
the higher order mechanism uses the same mechanisms (functions)
as the base system,&lt;p&gt;

With block-based higher order mechanisms, on the other hand,
we must make the argument an anonymous function (that's what
a block is), and we cannot use a named function, bringing
us back to the conundrum mentioned at the start that this
mechanisms encourages bad code.  Not only that, it also turns
out that the base mechanism (messages and methods) is different
from the higher order mechanism, which requires anonymous functions,
rather than methods.&lt;p&gt;

HOM currently solves only the latter part of this asymmetry, making
the higher order mechanism the same as the base mechanism, that
mechanism being messaging in both cases.   However, it currently 
cannot solve the other asymmetry:  where blocks support unnamed,
inline code and not named code, HOM supports named but not unnamed
code. While I think that this is the better choice in the larger
number of cases, it would be nice to actually suport both.&lt;p&gt;

One solution to this problem might be to simply support both blocks
and Higher Order Messaging, but it seems to me that the more 
elegant solution would be to support inline definition of more-or-less
anonymous methods that could then be integrated into the Higher Order
Messaging framework.&lt;p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-9046487851133964083?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/9046487851133964083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=9046487851133964083' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/9046487851133964083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/9046487851133964083'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/11/blocked-c-ii.html' title='Blocked-C II'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-842137603030076791</id><published>2009-11-07T22:55:00.001-08:00</published><updated>2009-11-08T15:37:02.394-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Objective-Smalltalk'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Exploring the Weather Underground with Objective-XML and Objective-Smalltalk</title><content type='html'>Having taken up &lt;a href="http://video.google.com/videosearch?hl=en&amp;client=safari&amp;rls=en&amp;q=paragliding+mussel+rock&amp;um=1&amp;ie=UTF-8&amp;ei=BGn2SpvlJY_ysQPy3OEd&amp;sa=X&amp;oi=video_result_group&amp;ct=title&amp;resnum=5&amp;ved=0CBcQqwQwBA#"&gt;various forms&lt;/a&gt; of &lt;a href="http://www.advantage-aviation.com/accomplishments.php"&gt;flying&lt;/a&gt; last year, I have developed a strong interest in the weather, particularly wind information.  While there are various web-sites with relevant information, for example Jeff Greenbaum's excellent &lt;a href="http://www.paragliding-lessons.com/Pacifica_Wind.htm"&gt;Wind Conditions Page for Pacifica&lt;/a&gt; page, they don't really present the information quite the way I need, and also don't really work well on small mobile devices...&lt;p&gt;

Fixing that should hopefully just be ASMOP.  The &lt;a href="http://www.wunderground.com/"&gt;Weather Underground&lt;/a&gt; fortunately has some reasonably well-documented &lt;a href="http://wiki.wunderground.com/index.php/API_-_XML"&gt;XML APIs&lt;/a&gt;, let's see what they have to offer and wether we can get to the data we want.&lt;p&gt; 

First, let's fire up the interactive Smalltalk Shell (stsh) and load the Objective-XML framework.
&lt;pre&gt;
marcel@spock[Projects]stsh
&amp;gt; context loadFramework:'MPWXmlKit'
&lt;/pre&gt;
Next, let's have a look at the raw XML returned by the Weather Underground APIs. 
&lt;pre&gt;
&amp;gt; urlstr:='http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=KCADALYC1'
&amp;gt; url:=NSURL URLWithString: urlstr
&amp;gt; NSString stringWithContentsOfURL:url.
&amp;gt; 
&lt;/pre&gt;
Hmm...no result.  (It turns out that Weather Underground checks the user agent and errors if it doesn't find one.  The various convenience methods do not send a User Agent).  Maybe curl can help?

&lt;pre&gt;
&amp;gt;context addExternalCommand:'curl'.
&amp;gt;curl run:'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=KCADALYC1'
&amp;lt;?xml version="1.0"?&amp;gt;
	&amp;lt;current_observation&amp;gt;
		&amp;lt;credit&amp;gt;Weather Underground Personal Weather Station&amp;lt;/credit&amp;gt;
		&amp;lt;credit_URL&amp;gt;http://wunderground.com/weatherstation/&amp;lt;/credit_URL&amp;gt;
		&amp;lt;image&amp;gt;
		&amp;lt;url&amp;gt;http://icons.wunderground.com/graphics/bh-wui_logo.gif&amp;lt;/url&amp;gt;
		&amp;lt;title&amp;gt;Weather Underground&amp;lt;/title&amp;gt;
		&amp;lt;link&amp;gt;http://wunderground.com/weatherstation/&amp;lt;/link&amp;gt;
		&amp;lt;/image&amp;gt;
		&amp;lt;location&amp;gt;
		&amp;lt;full&amp;gt;Mussel Rock, Daly City, CA&amp;lt;/full&amp;gt;
		&amp;lt;neighborhood&amp;gt;Mussel Rock&amp;lt;/neighborhood&amp;gt;
		&amp;lt;city&amp;gt;Daly City&amp;lt;/city&amp;gt;
		&amp;lt;state&amp;gt;CA&amp;lt;/state&amp;gt;
		&amp;lt;zip&amp;gt;&amp;lt;/zip&amp;gt;
		&amp;lt;latitude&amp;gt;37.667347&amp;lt;/latitude&amp;gt;
		&amp;lt;longitude&amp;gt;-122.489342&amp;lt;/longitude&amp;gt;
		&amp;lt;elevation&amp;gt;514 ft&amp;lt;/elevation&amp;gt;
		&amp;lt;/location&amp;gt;
		&amp;lt;station_id&amp;gt;KCADALYC1&amp;lt;/station_id&amp;gt;
		&amp;lt;station_type&amp;gt;Fan-aspirated Davis Vantage Pro 2 Plus&amp;lt;/station_type&amp;gt;
		&amp;lt;observation_time&amp;gt;Last Updated on November 7, 1:55 PM PST&amp;lt;/observation_time&amp;gt;
		&amp;lt;observation_time_rfc822&amp;gt;Sat, 07 November 2009 21:55:21 GMT&amp;lt;/observation_time_rfc822&amp;gt;
		&amp;lt;weather&amp;gt;&amp;lt;/weather&amp;gt;
		&amp;lt;temperature_string&amp;gt;56.9 F (13.8 C)&amp;lt;/temperature_string&amp;gt;
		&amp;lt;temp_f&amp;gt;56.9&amp;lt;/temp_f&amp;gt;
		&amp;lt;temp_c&amp;gt;13.8&amp;lt;/temp_c&amp;gt;
		&amp;lt;relative_humidity&amp;gt;83&amp;lt;/relative_humidity&amp;gt;
		&amp;lt;wind_string&amp;gt;From the NW at 15.0 MPH Gusting to 16.0 MPH&amp;lt;/wind_string&amp;gt;
		&amp;lt;wind_dir&amp;gt;NW&amp;lt;/wind_dir&amp;gt;
		&amp;lt;wind_degrees&amp;gt;313&amp;lt;/wind_degrees&amp;gt;
		&amp;lt;wind_mph&amp;gt;15.0&amp;lt;/wind_mph&amp;gt;
		&amp;lt;wind_gust_mph&amp;gt;16.0&amp;lt;/wind_gust_mph&amp;gt;
		&amp;lt;pressure_string&amp;gt;30.07" (1018.2 mb)&amp;lt;/pressure_string&amp;gt;
		&amp;lt;pressure_mb&amp;gt;1018.2&amp;lt;/pressure_mb&amp;gt;
		&amp;lt;pressure_in&amp;gt;30.07&amp;lt;/pressure_in&amp;gt;
		&amp;lt;dewpoint_string&amp;gt;51.8 F (11.0 C)&amp;lt;/dewpoint_string&amp;gt;
		&amp;lt;dewpoint_f&amp;gt;51.8&amp;lt;/dewpoint_f&amp;gt;
		&amp;lt;dewpoint_c&amp;gt;11.0&amp;lt;/dewpoint_c&amp;gt;
		
		&amp;lt;heat_index_string&amp;gt;&amp;lt;/heat_index_string&amp;gt;
		&amp;lt;heat_index_f&amp;gt;&amp;lt;/heat_index_f&amp;gt;
		&amp;lt;heat_index_c&amp;gt;&amp;lt;/heat_index_c&amp;gt;
		
		&amp;lt;windchill_string&amp;gt;&amp;lt;/windchill_string&amp;gt;
		&amp;lt;windchill_f&amp;gt;&amp;lt;/windchill_f&amp;gt;
		&amp;lt;windchill_c&amp;gt;&amp;lt;/windchill_c&amp;gt;
		
		&amp;lt;solar_radiation&amp;gt;483.00&amp;lt;/solar_radiation&amp;gt;
		&amp;lt;UV&amp;gt;2.5&amp;lt;/UV&amp;gt;
		&amp;lt;precip_1hr_string&amp;gt;0.00 in (0.0 mm)&amp;lt;/precip_1hr_string&amp;gt;
		&amp;lt;precip_1hr_in&amp;gt;0.00&amp;lt;/precip_1hr_in&amp;gt;
		&amp;lt;precip_1hr_metric&amp;gt;0.0&amp;lt;/precip_1hr_metric&amp;gt;
		&amp;lt;precip_today_string&amp;gt;0.01 in (0.0 mm)&amp;lt;/precip_today_string&amp;gt;
		&amp;lt;precip_today_in&amp;gt;0.01&amp;lt;/precip_today_in&amp;gt;
		&amp;lt;precip_today_metric&amp;gt;0.0&amp;lt;/precip_today_metric&amp;gt;
		&amp;lt;history_url&amp;gt;http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KCADALYC1&amp;lt;/history_url&amp;gt;
		&amp;lt;ob_url&amp;gt;http://www.wunderground.com/cgi-bin/findweather/getForecast?query=37.667347,-122.489342&amp;lt;/ob_url&amp;gt;
	&amp;lt;/current_observation&amp;gt;
&amp;lt;!-- 0.029:0 --&amp;gt;
&lt;/pre&gt;
Much better.  Now let's see if we can parse that XML data into a Cocoa Property List.
&lt;pre&gt;
&amp;gt; parser := MPWMAXParser parser.
&amp;gt; parser parsedDataFromURL: 'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=KCADALYC1'
{
    UV = "2.5";
    credit = "Weather Underground Personal Weather Station";
    "credit_URL" = "http://wunderground.com/weatherstation/";
    "dewpoint_c" = "11.1";
    "dewpoint_f" = "51.9";
    "dewpoint_string" = "51.9 F (11.1 C)";
    "heat_index_c" =     {
    };
    "heat_index_f" =     {
    };
    "heat_index_string" =     {
    };
    "history_url" = "http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KCADALYC1";
    image =     {
        link = "http://wunderground.com/weatherstation/";
        title = "Weather Underground";
        url = "http://icons.wunderground.com/graphics/bh-wui_logo.gif";
    };
    location =     {
        city = "Daly City";
        elevation = "514 ft";
        full = "Mussel Rock, Daly City, CA";
        latitude = "37.667347";
        longitude = "-122.489342";
        neighborhood = "Mussel Rock";
        state = CA;
        zip =         {
        };
    };
    "ob_url" = "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=37.667347,-122.489342";
    "observation_time" = "Last Updated on November 7, 1:55 PM PST";
    "observation_time_rfc822" = "Sat, 07 November 2009 21:55:51 GMT";
    "precip_1hr_in" = "0.00";
    "precip_1hr_metric" = "0.0";
    "precip_1hr_string" = "0.00 in (0.0 mm)";
    "precip_today_in" = "0.01";
    "precip_today_metric" = "0.0";
    "precip_today_string" = "0.01 in (0.0 mm)";
    "pressure_in" = "30.07";
    "pressure_mb" = "1018.2";
    "pressure_string" = "30.07\" (1018.2 mb)";
    "relative_humidity" = 83;
    "solar_radiation" = "482.00";
    "station_id" = KCADALYC1;
    "station_type" = "Fan-aspirated Davis Vantage Pro 2 Plus";
    "temp_c" = "13.9";
    "temp_f" = "57.0";
    "temperature_string" = "57.0 F (13.9 C)";
    weather =     {
    };
    "wind_degrees" = 342;
    "wind_dir" = NNW;
    "wind_gust_mph" = "24.0";
    "wind_mph" = "18.0";
    "wind_string" = "From the NNW at 18.0 MPH Gusting to 24.0 MPH";
    "windchill_c" =     {
    };
    "windchill_f" =     {
    };
    "windchill_string" =     {
    };
}
&lt;/pre&gt;
That looks good, we can see the wind information near the bottom of the output, with keys "wind_degrees" and "wind_mph".  So let's grab the values for those keys using the collect Higher Order Message and -objectForKey:. 
&lt;pre&gt;
&amp;gt; (parser parsedDataFromURL:'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=KCADALYC1' ) collect objectForKey: #( wind_mph wind_dir wind_string ) each. 
21.0
NW
From the NW at 21.0 MPH Gusting to 24.0 MPH
&lt;/pre&gt;
Almost what we wanted, except that we grabbed the wind direction as a string instead of the exact numeric direction.  Easy fix:
&lt;pre&gt;
&amp;gt; (parser parsedDataFromURL: 'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=KCADALYC1' ) collect objectForKey: #( wind_mph wind_degrees wind_string ) each.
12.0
318
From the NW at 12.0 MPH Gusting to 24.0 MPH
&amp;gt;
&lt;/pre&gt;
Perfect.  We have the wind speed, the direction and an informative text in case we want to display that.
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-842137603030076791?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/842137603030076791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=842137603030076791' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/842137603030076791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/842137603030076791'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/11/exploring-weather-underground-with.html' title='Exploring the Weather Underground with Objective-XML and Objective-Smalltalk'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-6085482498787548154</id><published>2009-11-06T00:24:00.001-08:00</published><updated>2009-11-07T13:39:32.962-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Higher Order Messaging'/><category scheme='http://www.blogger.com/atom/ns#' term='Blocks'/><category scheme='http://www.blogger.com/atom/ns#' term='Cocoa'/><title type='text'>Blocked-C</title><content type='html'>&lt;b&gt;Update:&lt;/b&gt;  It appears that the original article has been removed, and has been superseded by material at: &lt;a href="http://developer.apple.com/mac/articles/cocoa/introblocksgcd.html"&gt;http://developer.apple.com/mac/articles/cocoa/introblocksgcd.html&lt;/a&gt;.  The original article had more on the Cocoa block APIs and gave a refreshingly honest assessment of the for-loop vs. Block-iteration comparison.&lt;p&gt;


While the news that Apple is adding blocks to C and Objective-C in the SnowLeopard time frame has been around for some time, a recent &lt;a href="https://developer.apple.com/mac/articles/snowleopard/usingblockswithgrandcentraldispatch.html"&gt;article&lt;/a&gt; shed some light on the actual API.&lt;p&gt;

While there probably are some places where Objective-C blocks can be useful, I am not really impressed.  In the following samples, &lt;font color="ff0000"&gt;red&lt;/font&gt; is used to show &lt;a href="http://www.metaobject.com/blog/2009/01/semantic-noise.html"&gt;noise&lt;/a&gt;, meaning code that is just there to make the compiler happy.
&lt;hr&gt;
&lt;blockquote&gt;
&lt;pre&gt;

&lt;font color="ff0000"&gt;NSMutableArray *&lt;/font&gt;filteredItems= &lt;font color="ff0000"&gt;[NSMutableArray array];
&lt;/font&gt;[items enumerateObjects&lt;font color="ff0000"&gt;WithOptions:0 withBlock:
    ^(id item, NSUInteger index, BOOL *stop) {
        [filteredItems addObject:[item &lt;/font&gt;stringByAppendingString:@"suffix"&lt;font color="ff0000"&gt;]];
    }
];&lt;/font&gt;
&lt;/pre&gt;
&lt;/font&gt;
&lt;/blockquote&gt;
&lt;hr&gt;

As you can see, the version using blocks is very, very noisy, both syntactically and semantically, especially compared with the &lt;a href="http://www.metaobject.com/papers/Higher_Order_Messaging_OOPSLA_2005.pdf" &gt;HOM&lt;/a&gt; version:

&lt;hr&gt;
&lt;blockquote&gt;
&lt;pre&gt;
&lt;font color="ff0000"&gt;[[&lt;/font&gt;items collect&lt;font color="ff0000"&gt;]&lt;/font&gt; stringByAppendingString:@"suffix"&lt;font color="ff0000"&gt;];&lt;/font&gt;
&lt;/pre&gt;
&lt;/font&gt;
&lt;/blockquote&gt;
&lt;hr&gt;

No prizes for guessing which I'd prefer.  To put some numbers on my preference:  234 characters vs. 52, 19 tokens vs. 3, 5 lines vs. 1.  In fact, even a plain old C for-loop is more compact and less noisy than our "modern" blocked version:

&lt;hr&gt;
&lt;blockquote&gt;
&lt;pre&gt;
&lt;font color="ff0000"&gt;NSMutableArray *&lt;/font&gt;filteredItems= &lt;font color="ff0000"&gt;[NSMutableArray array];
for (int i=0; i &amp;lt; [items count]; i++ ) {
     [filteredItems addObject:[&lt;/font&gt;items &lt;font color="ff0000"&gt;objectAtIndex:i] &lt;/font&gt;stringByAppendingString:@"suffix"&lt;font color="ff0000"&gt;];
    }
];&lt;/font&gt;
&lt;/pre&gt;
&lt;/font&gt;
&lt;/blockquote&gt;
&lt;hr&gt;

&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-6085482498787548154?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/6085482498787548154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=6085482498787548154' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/6085482498787548154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/6085482498787548154'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/11/blocked-c.html' title='Blocked-C'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-383704232621896542</id><published>2009-11-05T23:08:00.001-08:00</published><updated>2009-11-05T23:08:05.388-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><title type='text'>Why not Objective-C?</title><content type='html'>Patrick Logan &lt;a href="http://patricklogan.blogspot.com/2008/05/objectively.html"&gt;can't understand&lt;/a&gt; why projects use C++ rather than Ojective-C.  Neither can I.&lt;p&gt;

For the 95% (or more) of code that isn't performance sensitive, it gives you expressiveness very close to Smalltalk, and for the 5% or less that need high performance, it gets you the performance and predictability of C. &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-383704232621896542?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/383704232621896542/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=383704232621896542' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/383704232621896542'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/383704232621896542'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/11/why-not-objective-c.html' title='Why not Objective-C?'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-5443311908713019379</id><published>2009-09-20T00:13:00.001-07:00</published><updated>2009-09-20T00:13:27.889-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Memory management'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><category scheme='http://www.blogger.com/atom/ns#' term='Cocoa'/><title type='text'>Cocoa(touch) memory management is as easy as 1-2-3</title><content type='html'>There is a common &lt;a href="http://broadcast.oreilly.com/2009/06/big-learning-curve-for-iphone.html"&gt;misconception&lt;/a&gt; that Cocoa memory management is hard.  It's not.&lt;p&gt;

&lt;ol&gt;
&lt;li&gt;Use auto-generated accessors religiously&lt;/li&gt;
&lt;li&gt;Release your instance variables in dealloc&lt;/li&gt;
&lt;li&gt;Always use convenience methods to create objects&lt;/li&gt;
&lt;/ol&gt;

Wow, that wasn't too hard!&lt;p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-5443311908713019379?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/5443311908713019379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=5443311908713019379' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/5443311908713019379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/5443311908713019379'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/09/cocoatouch-memory-management-is-as-easy.html' title='Cocoa(touch) memory management is as easy as 1-2-3'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-7834470163936763598</id><published>2009-02-08T14:27:00.001-08:00</published><updated>2009-02-08T14:28:04.343-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Objective-XML-5.0.1</title><content type='html'>Just pushed out a minor bugfix release to Objective-XML-5.0:
&lt;ul&gt;
&lt;li&gt;Re-enabled character-set conversion code that had gotten disabled&lt;/li&gt;
&lt;li&gt;Fixed a compile-error for some targets&lt;/li&gt;
&lt;li&gt;Other minor improvements&lt;/li&gt;

&lt;/ul&gt;

Download here: &lt;a href="http://www.metaobject.com/downloads/Objective-C/Objective-XML-5.0.1.tgz"&gt;http://www.metaobject.com/downloads/Objective-C/Objective-XML-5.0.1.tgz&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-7834470163936763598?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/7834470163936763598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=7834470163936763598' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/7834470163936763598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/7834470163936763598'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/02/objective-xml-501.html' title='Objective-XML-5.0.1'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-8191601417333060557</id><published>2009-01-25T14:21:00.001-08:00</published><updated>2009-01-25T14:21:08.274-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Objective-XML 5.0</title><content type='html'>I've just pushed out a new release of Objective-XML, with some pretty significant new features.

&lt;h4&gt;Incremental parsing&lt;/h4&gt;

This feature, which was already discussed a little in an earlier post, is now available in an official release.  In short, Objective-XML will now stream data from network data sources (specified by URL) and produce results incrementally, rather than reading all of the data first and then parsing it.  This can make a huge difference in responsiveness and perceived performance for slow networks.  CPU and memory consumption will be slightly higher because of extra buffering and buffer stitching required, so this should only be used when necessary.

&lt;h4&gt;Static iPhone library&lt;/h4&gt;

Although Objective-XML has always been compatible with the iPhone, previous releases required copying the pre-requisite files into your project.  This burden has now been eased by the inclusion of a static library target.  You still need to copy the headers, either MPWMAXParser.h or MPWXmlParser.h (or both).

&lt;h4&gt;Unique keys&lt;/h4&gt;

Previous releases of Objective-XML had an -objectForTag:(int)tag method for quickly retrieving attribute or element values. &lt;p&gt;
&lt;hr&gt;
&lt;blockquote&gt;
&lt;pre&gt;
enum songtags {
  item_tag=10, title_tag, category_tag	
};
...
  [parser setHandler:self forElements:[NSArray arrayWithObjects:@"item",@"title",@"category",nil]
          inNamespace:nil prefix:@"" map:nil tagBase:item_tag];
...
-itemElement:(MPWXMLAttributes*)children attributes:(MPWXMLAttributes*)attributes parser:(MPWMAXParser*)p
{
   ...
   [song setTitle:[children objectForTag:title_tag]];
   ...
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;hr&gt;
Objective-XML adds an -objectForUniqueKey:aKey method that removes the need for these additional integer tags.
&lt;hr&gt;
&lt;blockquote&gt;
&lt;pre&gt;
...
  [parser setHandler:self forElements:[NSArray arrayWithObjects:@"item",@"title",@"category",nil]
          inNamespace:nil prefix:@"" map:nil];
...
-itemElement:(MPWXMLAttributes*)children attributes:(MPWXMLAttributes*)attributes parser:(MPWMAXParser*)p
{
   ...
   [song setTitle:[children objectForUniqueKey:@"title"]];
   ...

&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;hr&gt;

In addition to providing faster access, the integer tags also served to disambiguate tag names that might occur in multiple namespaces.  To handle these conflicts, there now is a -objectForUniqueKey:aKey namespace:aNamespace method.  The namespace objects required for this disambiguation process are now returned by the -setHandler:... and -declareAttributes:... methods, which were previously void.

&lt;h4&gt;Default methods&lt;/h4&gt;

One of the attractive features of DOM parsers is that they do something useful "out of the box":  point a DOM parser at some XML and you get back a generic in-memory representation of that XML that you can then start taking apart.  However, once you go down that road, you are stuck with the substantial CPU and memory overheads of that generic representation.&lt;p&gt;

Streaming parser like SAX or MAX can be a lot more efficient, but it takes a lot more time and effort until achieving a first useful result.  Default methods overcome this hurdle by also delivering an immediately useful generic representation without any extra work.  Unlike a DOM, however, this generic representation can be incrementally replaced by more specialized and efficient processing later on.&lt;p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-8191601417333060557?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/8191601417333060557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=8191601417333060557' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/8191601417333060557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/8191601417333060557'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/01/objective-xml-50.html' title='Objective-XML 5.0'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-3708601404734017378</id><published>2009-01-20T10:39:00.001-08:00</published><updated>2009-01-20T10:39:53.525-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Cocoa HTML parsing with Objective-XML</title><content type='html'>Although Objective-XML's MPWSAXParser mostly provides NSXMLParser compatibility it also provides a number of useful additional features.  Among these features is the ability to parse HTML files via the settings of two flags:  &lt;b&gt;enforceTagNesting&lt;/b&gt; and &lt;b&gt;ignoreCase&lt;/b&gt;.  By default, these are on and off, respectively, which gives you strict XML behavior.  However, by setting   &lt;b&gt;enforceTagNesting&lt;/b&gt; to NO and &lt;b&gt;ignoreCase&lt;/b&gt; to YES, you get a SAX parser that will happily and speedily process HTML.&lt;p&gt;

&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-3708601404734017378?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/3708601404734017378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=3708601404734017378' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/3708601404734017378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/3708601404734017378'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/01/cocoa-html-parsing-with-objective-xml.html' title='Cocoa HTML parsing with Objective-XML'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-8267842734052308706</id><published>2009-01-17T23:57:00.001-08:00</published><updated>2009-01-18T02:08:10.405-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Higher Order Messaging'/><category scheme='http://www.blogger.com/atom/ns#' term='Blocks'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><title type='text'>Semantic Noise</title><content type='html'>&lt;a href="http://martinfowler.com"&gt;Martin Fowler&lt;/a&gt; and &lt;a href="http://gbracha.blogspot.com/2007/01/parser-combinators.html"&gt;Gilad Bracha&lt;/a&gt; write about &lt;a href="http://martinfowler.com/bliki/SyntacticNoise.html"&gt;Syntactic Noise&lt;/a&gt;, making similar points and using similar typographical techniques as I did in my &lt;a href="http://www.metaobject.com/papers/Higher_Order_Messaging_OOPSLA_2005.pdf"&gt;HOM paper&lt;/a&gt;.

&lt;blockquote&gt;
By Syntactic Noise, what people mean is extraneous characters that aren't part of what we really need to say, but are there to satisfy the language definition. Noise characters are bad because they obscure the meaning of our program, forcing us to puzzle out what it's doing.
&lt;/blockquote&gt;

Couldn't have said it better myself, so I'll just quote Martin Fowler.  Syntactic noise is one of the reasons I think neither the for(each) statement nor the blocks added to Objective-C are particularly good replacements for Higher Order Messaging.

&lt;hr&gt;
&lt;blockquote&gt;
&lt;pre&gt;
&lt;font face="Courier" size="-3"&gt;newArray = &lt;font color="ff0000"&gt;[&lt;/font&gt;existingArray map:&lt;font color="ff0000"&gt;^(id obj){ return [obj &lt;/font&gt; stringByAppendingString:&lt;font color="ff0000"&gt;@"&lt;/font&gt;suffix"&lt;font color="ff0000"&gt;]; }];&lt;/font&gt;
newArray = &lt;font color="ff0000"&gt;[[&lt;/font&gt;existingArray map&lt;font color="ff0000"&gt;]&lt;/font&gt; stringByAppendingString:@"suffix"&lt;font color="ff0000"&gt;]];&lt;/font&gt;
&lt;/pre&gt;
&lt;/font&gt;
&lt;/blockquote&gt;
&lt;hr&gt;

To me, that extra syntax is quite noisy, though the noise isn't, in fact, just syntactic.  We also have to introduce, name and even correctly type a completely redundant stand-in (&lt;font color="ff0000"&gt;obj&lt;/font&gt;) that we don't really care about.  Introducing &lt;a href="http://en.wikipedia.org/wiki/Occam's_razor"&gt;extra entities&lt;/a&gt; is semantic noise.  Apart from having to puzzle out what that extra entity is (and that it is, in fact, redundant) every time we read the code, it also brings us back to &lt;a href="http://www.stanford.edu/class/cs242/readings/backus.pdf"&gt;"element at a time"&lt;/a&gt; programming and thinking.
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-8267842734052308706?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/8267842734052308706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=8267842734052308706' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/8267842734052308706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/8267842734052308706'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/01/semantic-noise.html' title='Semantic Noise'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-3114638642670394043</id><published>2009-01-15T11:26:00.001-08:00</published><updated>2009-01-15T11:39:29.175-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Higher Order Messaging'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><title type='text'>Simple HOM</title><content type='html'>While it is good to see that Higher Order Messaging is still inspiring new work, I feel a bit guilty that part of that inspiration are sentiments such as the &lt;a href="http://seriot.ch/blog.php?article=20090109"&gt;following&lt;/a&gt;:&lt;p&gt;
&lt;blockquote&gt;
 "Still I have yet to find a simple implementation that I like and that does not use private methods. The last thing I want is a relying on classes which can break at any time."
&lt;/blockquote&gt;
Mea culpa.&lt;p&gt;
While I did &lt;a href="http://www.metaobject.com/blog/2007/11/better-hom-selects.html"&gt;explain&lt;/a&gt; a bit why the current HOM implementation is a bit gnarly, code probably speaks more loudly than repeated mea-culpas.&lt;p&gt;

So, without further ado, a really simple HOM implementation.  An NSArray category provides the interface and does the actual processing:

&lt;blockquote&gt;
&lt;pre&gt;
@interface NSArray(hom)

-collect;

@end

@implementation NSArray(hom)

-(NSArray* )collect:(NSInvocation*)anInvocation
{
  NSMutableArray *resultArray=[NSMutableArray array];
  for (id obj in self ) {
    id resultObject;
    [anInvocation invokeWithTarget:obj];
    [anInvocation getReturnValue:&amp;resultObject];
    [resultArray addObject:resultObject];
  }
  return resultArray;
}

-collect {
  return [HOM homWithTarget:self selector:@selector(collect:)];
}

@end
&lt;/pre&gt;
&lt;/blockquote&gt;

The fact that NSInvocation deals with pointers to values rather than values makes this a bit longer than it needs to be, but the gist is simple enough:  iterate over the array, invoke the invocation, return the result.&lt;p&gt;

That leaves the actual trampoline, which is really just an implementation detail for conveniently creating NSInvocation objects.
&lt;blockquote&gt;
&lt;pre&gt;

@interface HOM : NSProxy {
  id xxTarget;
  SEL xxSelector;
}

@end

@implementation HOM

-(void)forwardInvocation:(NSInvocation*)anInvocation
{
  [xxTarget performSelector:xxSelector withObject:anInvocation];
}

-methodSignatureForSelector:(SEL)aSelector
{
  return [[xxTarget objectAtIndex:0] methodSignatureForSelector:aSelector];
}

-xxinitWithTarget:aTarget selector:(SEL)newSelector
{
  xxTarget=aTarget;
  xxSelector=newSelector;
  return self;
}

+homWithTarget:aTarget selector:(SEL)newSelector
{
  return [[[self alloc] xxinitWithTarget:aTarget selector:newSelector] autorelease];
}

@end
&lt;/pre&gt;
&lt;/blockquote&gt;

This code compiles without warnings, does not use any private API, and runs on both Leopard and the iPhone.   The Xcode project can be downloaded &lt;a href="http://www.metaobject.com/downloads/Objective-C/SimpleHom-1.0.tgz"&gt;here&lt;/a&gt;.&lt;p&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-3114638642670394043?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/3114638642670394043/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=3114638642670394043' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/3114638642670394043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/3114638642670394043'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/01/simple-hom.html' title='Simple HOM'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-1529330234451847130</id><published>2009-01-11T16:01:00.001-08:00</published><updated>2009-01-12T09:12:57.294-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>iPhone XML performance</title><content type='html'>Shortly after becoming an iPhone developer, I found a clever little piece of example code called &lt;a href="http://developer.apple.com/iphone/library/samplecode/XMLPerformance/index.html"&gt;XML Performance&lt;/a&gt; (login required).  Having done some &lt;a href="http://www.metaobject.com/Technology/index.html#Objective-XML"&gt;high performance XML processing code&lt;/a&gt; that works on the iPhone, I was naturally intrigued.&lt;p&gt;

The example pits Cocoa's NSXMLParser against a custom parser based on libxml2, the benchmark is downloading a top 300 list of songs from iTunes.  


&lt;h4&gt;More responsiveness using libxml2 instead of NSXMLParser&lt;/h4&gt;

Based on my previous experience, I was expecting libxml2 to be noticeably faster, but with the advantage in processing speed being less and less important with lower and lower I/O data rates (WiFi to 3G to Edge), as I/O would start to completely overwhelm processing.  Was I ever wrong!&lt;p&gt;

While my expectations were technically correct for overall performance, I had completely failed to take responsiveness into account.  Depending on the network selected, the NSXMLParser sample would appear to hang for 3 to 50 seconds before starting to show results.  Needless to say, that is an awful user experience.  The libxml example, on the other hand, would start displaying some results almost immediately.  While it also was a bit faster in the total time taken, this effect seemed pretty insignificant compared to the fact that results were arriving continually pretty much during the entire time.&lt;p&gt;

The difference, of course, is incremental processing.  Whereas NSXMLParser's -initWithContentsOfURL: method apparently downloads the entire document first and then begins processing, the libxml2-based code in the sample downloads the XML in small chunks and processes those chunks immediately.&lt;p&gt;

Alas, going with libxml2 has clear and significant disadvantages, with the code that uses libxml2 being around twice the size of the NSXMLParser-based code, at around 150 lines (non-comment, non-whitespace).  If you have worked with NSXMLParser before, you will know that that is already pretty painful, so just imagine that particular brand of joy doubled, with the 150 lines of code giving you the simplest of parsers, with just 5 tags processed.  Fortunately, there is a simpler way.

&lt;h4&gt;A simpler way:  Objective-XML's SAX&lt;/h4&gt;

Assuming you have already written a Cocoa-(Touch-)based parser using NSXMLParser, all you need to do is include Objective-XML in your projects and replace the reference to NSXMLParser with a reference to MPWSAXParser, everything else will work just as before.  Well, the same except for being significantly faster (even faster than libxml2) and now also more responsive on slow connections due to incremental processing.&lt;p&gt;

I have to admit that not having incremental processing was a "feature" Objective-XML shared with NSXMLParser until very recently, due to my not taking into account the fact that &lt;a href="http://www.ll.mit.edu/HPEC/agendas/proc04/invited/patterson_keynote.pdf"&gt;latency lags bandwidth&lt;/a&gt;.  This silly oversight has now been fixed, with both MPWMAXParser and MPWSAXParser sporting URL-based parsing methods that do incremental processing.&lt;p&gt;

So that's all there is to it, Objective-XML provides a drop-in replacement for NSXMLParser that has all the performance and responsiveness-benefits of a libxml2-based solution without the coding horror.

&lt;h4&gt;Even simpler: Messaging API for XML (MAX)&lt;/h4&gt;

However, even a Cocoa version of the SAX API represents a pretty low-bar in terms of ease of coding.  With MAX, Objective-XML provides an API that can do the same job much more simply.  MAX naturally integrates XML processing with Objective-C messaging using the following two main features:
&lt;ul&gt;
&lt;li&gt;Clients get sent element-specific messages for processing&lt;/li&gt;
&lt;li&gt;The parser handles nesting, controlled by the client&lt;/li&gt;

&lt;/ul&gt;

The following code for building Song objects out of iTunes &amp;lt;item&amp;gt; elements illustrates these two features:

&lt;blockquote&gt;
&lt;pre&gt;
-itemElement:(MPWXMLAttributes*)children attributes:(MPWXMLAttributes*)attributes parser:(MPWMAXParser*)p
{
  Song *song=[[Song alloc] init];
  [song setArtist:[children objectForTag:artist_tag]];
  [song setAlbum:[children objectForTag:album_tag]];
  [song setTitle:[children objectForTag:title_tag]];
  [song setCategory:[children objectForTag:category_tag]];
  [song setReleaseDate:[parseFormatter dateFromString:[children objectForTag:releasedate_tag]]];
  [self parsedSong:song];
  [song release];
  return nil;
}
&lt;/pre&gt;
&lt;/blockquote&gt;

MAX sends the -itemElement:attributes:parser: message to its client whenever it has encountered a complete &amp;lt;item&amp;gt; element, so there is no need for the client to perform string processing on tag names or
manage partial state as in a SAX parser.
The method constructs a song object using data from the &amp;lt;item&amp;gt; element's child elements which it then passes directly to the rest of the app via the parsedSong: message.  It does not return an value, so MAX will not build a tree at this level.&lt;p&gt;

Artist, album, title and category are the values of nested child elements of the &amp;lt;item&amp;gt; element.   The (common) code shared by all these child-elements gets the character content of the respective elements and is shown below:

&lt;blockquote&gt;
&lt;pre&gt;
-defaultElement:children attributes:atrs parser:parser
{
	return [[children combinedText] retain];
}
&lt;/pre&gt;
&lt;/blockquote&gt;

Unlike the &amp;lt;item&amp;gt; processing code, which did not return a value, this method does return a value.  MAX uses this return value to build
a DOM-like structure which is then consumed by the next higher-level, in this case the  -itemElement:attributes:parser: method shown above.  Unlike a traditional DOM, the MAX tree structure is built out of domain-specific objects returned incrementally by the client.&lt;p&gt;

These two pieces of sample code demonstrate how MAX can act like both a DOM parser or a SAX parser, controlled simply by wether the processing methods return objects (DOM) or not (SAX).  They also demonstrated both element-specific and generic processing.&lt;p&gt;

In the iTunes Song parsing example, I was able to build a MAX parser using about half the code required for the NSXMLParser-based example, a ratio that I have also encountered in larger projects.  What about performance?  It is slightly better than MPWSAXParser, so also somewhat better than libxml2 and significantly better than NSXMLParser.

&lt;h4&gt;Summary and Conclusion&lt;/h4&gt;

The slightly misnamed XML Performance sample code for the iPhone demonstrates how important managing latency is for perceived end user performance, while showing only very little in terms of actual XML processing performance.&lt;p&gt;

While ably demonstrating the performance problems of NSXMLParser, the sample code's solution of using libxml2 is really not a solution, due to the significant increase in code complexity.  Objective-XML provides both a drop-in replacement for NSXMLParser with all the performance and latency benefits of the libxml2 solution, as well as a new API that is not just faster, but also much more straightforward than either NSXMLParser or libxml2.&lt;p&gt;

&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-1529330234451847130?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/1529330234451847130/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=1529330234451847130' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/1529330234451847130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/1529330234451847130'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/01/iphone-xml-performance.html' title='iPhone XML performance'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-8836488921722500253</id><published>2009-01-11T14:22:00.001-08:00</published><updated>2009-01-11T17:51:33.959-08:00</updated><title type='text'>Best of Show, MacWorld 2009</title><content type='html'>Since I recently became the Mac tech lead for &lt;a href="http://www.livescribe.com/"&gt;Livescribe&lt;/a&gt;, responsible for delivering the Mac desktop software, I am happy to report that not only did we meet all of our &lt;a href="http://odeo.com/episodes/23629821-Livescribe-digital-pen-is-Mac-ready"&gt;target&lt;/a&gt; &lt;a href="http://www.gizmodo.com.au/2008/11/livescribe_pulse_smartpen_is_finally_mac_compatible.html"&gt;dates&lt;/a&gt;, we also won &lt;a href="http://www.macworld.com/article/138002-8/2009/01/bos2009.html"&gt;Best of Show&lt;/a&gt; at MacWorld 2009.&lt;p&gt;

Spending 3 days at the booth was both exhausting and rewarding, the &lt;a href="http://www.macworld.com/article/138067/2009/01/expo_notes_livescribe_booth_packed.html?lsrc=rss_main"&gt;enthusiasm&lt;/a&gt; &lt;a href="http://www.youtube.com/watch?v=_AZNMzjKYb8"&gt;exhibited&lt;/a&gt; by customers was absolutely mind-blowing.&lt;p&gt;

&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-8836488921722500253?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/8836488921722500253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=8836488921722500253' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/8836488921722500253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/8836488921722500253'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2009/01/best-of-show-macworld-2009.html' title='Best of Show, MacWorld 2009'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-5158058258246801503</id><published>2008-12-24T18:35:00.001-08:00</published><updated>2008-12-24T18:42:24.492-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Testing'/><title type='text'>More on one test class per class</title><content type='html'>I knew there was some other place &lt;a href="http://www.metaobject.com/blog/2008/12/unit-test-class.html"&gt;this recommendation&lt;/a&gt; had recently popped up:  &lt;a href="http://www.amazon.com/Emergent-Design-Evolutionary-Professional-Development/dp/0321509366"&gt;"Emergent Design"&lt;/a&gt; by Scott Bain, via &lt;a href="http://www.cincomsmalltalk.com/userblogs/ralph/blogView?showComments=true&amp;printTitle=Emergent_design,_and_refactoring_in_large_projects&amp;entry=3405976049"&gt;Ralph Johnson&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-5158058258246801503?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/5158058258246801503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=5158058258246801503' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/5158058258246801503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/5158058258246801503'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2008/12/more-on-test-class-per-class.html' title='More on one test class per class'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-398410128493973413</id><published>2008-12-20T15:45:00.001-08:00</published><updated>2008-12-22T14:21:18.353-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><title type='text'>Unit test the class</title><content type='html'>Travis Griggs comes to the &lt;a href="http://www.cincomsmalltalk.com/userblogs/travis/blogView?showComments=true&amp;printTitle=Unit_Testing&amp;entry=3373495029"&gt;conclusion&lt;/a&gt; that unit test objects
should map 1:1 to classes under test.&lt;p&gt;
I agree.&lt;p&gt;
In fact, I would go a bit further:  tests should be an integral part of a class.  While this helps avoid negative outcomes such as &lt;a href="http://www.soberit.hut.fi/mmantyla/badcodesmellstaxonomy.htm"&gt;parallel&lt;/a&gt; &lt;a href="http://books.google.com/books?id=1MsETFPD3I0C&amp;pg=PA83&amp;lpg=PA83&amp;dq=Parallel+Class+Hierarchy+fowler&amp;source=web&amp;ots=pKN7s_UDcd&amp;sig=vMlHIhUDA2xLBoCvsHKPePec5yQ&amp;hl=en&amp;sa=X&amp;oi=book_result&amp;resnum=1&amp;ct=result"&gt;class&lt;/a&gt; &lt;a href="http://www.codinghorror.com/blog/archives/000589.html"&gt;hierarchies&lt;/a&gt; or having code and tests diverge, it more importantly simplifies the test/code relationship and drives home the point that code is incomplete without its tests.&lt;p&gt;

While I was working with JUnit on a reasonably large Java system, both finding a good place for a particular test and finding the tests for a specific class became quite burdensome after a while.&lt;p&gt;

For this reason &lt;a href="http://www.metaobject.com/Technology/#MPWTest"&gt;MPWTest&lt;/a&gt; simply asks classes to test themselves.  Furthermore, only frameworks are tested, so the test tool simply loads each framework to test, enumerates the classes within that particular framework and then runs the tests it finds.  TestCases and TestSuites are implicitly created from this structure, removing most of the administrative burdens of unit testing, and also any explicit dependence of the tests on the testing framework.&lt;p&gt;

Having no dependencies on the testing framework makes it easier to ship tests in production code without having to also ship the testing framework.  While this may sound odd at first, it avoids potential issues with code compiled for testing being different than code destined to be shipped, and further reinforces the idea that tests are an integral part of each class, rather than an optional add-on.&lt;p&gt;



&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-398410128493973413?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/398410128493973413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=398410128493973413' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/398410128493973413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/398410128493973413'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2008/12/unit-test-class.html' title='Unit test the class'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-8715235209615330510</id><published>2008-10-11T18:44:00.001-07:00</published><updated>2008-10-12T08:59:20.476-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Binary XML</title><content type='html'>Jimmy Zhang hits the nail on the head when he &lt;a href="http://xml.sys-con.com/read/250512.htm"&gt;notes&lt;/a&gt; that parsing ASCII text is not the primary problem in XML performance, object allocation is.  I was
surprised by the same finding when I started working on Objective-XML around a decade ago.&lt;p&gt;


Sean McGrath claims that &lt;a href="http://seanmcgrath.blogspot.com/2008/01/binary-xml-solves-wrong-problem.html"&gt;Binary XML solves the wrong problem&lt;/a&gt;.&lt;p&gt;

Yes and no:  it doesn't help much with existing structures and parsing methods, but with the right methods, it can be extremely helpful!&lt;p&gt;

Also:  "...how weird is it that we have not moved on from the DOM and SAX in terms of "standard" APIs for XML processing?"
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-8715235209615330510?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/8715235209615330510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=8715235209615330510' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/8715235209615330510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/8715235209615330510'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2008/10/binary-xml.html' title='Binary XML'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-6458468706458471009</id><published>2008-08-09T21:39:00.001-07:00</published><updated>2008-08-09T21:39:00.293-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Refactoring'/><category scheme='http://www.blogger.com/atom/ns#' term='Agile'/><title type='text'>Code is not an asset</title><content type='html'>&lt;p&gt;&lt;a href="http://michaelfeathers.typepad.com/michael_feathers_blog/"&gt;Michael Feathers&lt;/a&gt; wonders how to go &lt;a href="http://michaelfeathers.typepad.com/michael_feathers_blog/2008/08/beyond-technica.html"&gt;beyond technical debt&lt;/a&gt;.  I have been wondering about this for some time, and I think the answer is to account for code as a liability, not an asset.&lt;/p&gt;

&lt;p&gt;The functionality that the code has, the value it delivers is an asset, but the code itself is a liability.  This easily explains how refactoring and removing code add value, as long as functionality is preserved.
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-6458468706458471009?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/6458468706458471009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=6458468706458471009' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/6458468706458471009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/6458468706458471009'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2008/08/code-is-not-asset.html' title='Code is not an asset'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-5786690447800980125</id><published>2008-04-20T13:57:00.001-07:00</published><updated>2008-04-20T13:57:03.222-07:00</updated><title type='text'>Higher Order Messaging backgrounded</title><content type='html'>
&lt;a href="http://www.bofh.org.uk/articles/2007/05/19/domain-agnostic-languages"&gt;Piers Cawley&lt;/a&gt; talks 
about &lt;a href="http://rspec.info/"&gt;RSpec&lt;/a&gt;'s use of &lt;a href="http://www.metaobject.com/Research/"&gt;HOM&lt;/a&gt;:

&lt;blockquote&gt;It is, however, encouraging to see initiatives like Rspec which, through judicious use of higher order messages enables a much more fluent environment for writing tests: &lt;/blockquote&gt;

I think that's the first time I've seen HOM used to explain something else, rather than being the
&lt;a href="http://nat.truemesh.com/archives/000535.html"&gt;object&lt;/a&gt; of &lt;a href="http://www.devchix.com/2007/05/25/ruby-dry-up-your-enumerations/"&gt;attention&lt;/a&gt; itself.  So HOM is starting to be seen as simply a part of the computing landscape, at least by some.  Cool.

HOM was never conceived of as an interesting thing by itself but rather as a (meta-)building block for
building more expressive computational forms.  RSpec looks exactly like one of those cool things HOM 
enables that I would never have come up with myself.  I look forward to seeing more.
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-5786690447800980125?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/5786690447800980125/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=5786690447800980125' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/5786690447800980125'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/5786690447800980125'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2008/04/higher-order-messaging-backgrounded.html' title='Higher Order Messaging backgrounded'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-1602973155561144165</id><published>2008-04-19T21:42:00.001-07:00</published><updated>2008-04-20T14:13:51.025-07:00</updated><title type='text'>Not just high performance Objective-C</title><content type='html'>Addendum to my &lt;a href="http://www.metaobject.com/blog/2007/08/high-performance-objective-c-i.html"&gt;article&lt;/a&gt; on implementing a high performance Postscript interpreter in Objective-C:  not just is performance better, so is accuracy.

Despite the fact that we are optimizing the heck out of the Objective-C objects we are using, they still
give us encapsulation and polymorphism, allowing us to choose arbitrary representations.  For example,
most Postscript interpreters use a fixed-size value object (polymorphic in a C-union type of way) 
that constraints floating point precision to 32 bits.  With Objective-C, we have no such constraints,
so EGOS floats are actually 64 bit doubles, so running the modified benchmark below in PostView doesn't just yield the result 75% faster than Preview, it also produces it with 7 orders of magnitude less error.  Not that that is necessarily important in Postscript, but it is a pleasant side effect and shows the power of combining performance with abstraction.


&lt;pre&gt;
%!
  usertime
  1000 0 1 10000000 { pop 0.0001 sub  } bind for
  exch usertime exch sub dup ==
  20 20 moveto /Times-Roman 24 selectfont
  100 string cvs show ( ms) show ( error:  ) show 
  1000.0 div 100.0 mul abs  100 string cvs show ( %) show
  showpage
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-1602973155561144165?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/1602973155561144165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=1602973155561144165' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/1602973155561144165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/1602973155561144165'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2008/04/not-just-high-performance-objective-c.html' title='Not just high performance Objective-C'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-4715721926048787685</id><published>2007-11-28T18:27:00.001-08:00</published><updated>2007-11-28T18:27:25.863-08:00</updated><title type='text'>Better HOM selects</title><content type='html'>Wincent Colaiuta &lt;a href="http://wincent.com/a/about/wincent/weblog/archives/2006/11/hom_improvement.php"&gt;discusses&lt;/a&gt; a variant of the select HOM that takes an arbitrary number of
argument messages.  I like it!&lt;p&gt;

My initial implementation actually had arbitrary nesting, but as he discusses with collect, that
requires a trigger message to start, as there is no way of knowing at runtime when the expression terminates.  It never occurred to me that this limitation did not apply to select, which can
look at the return type of the messages sent and stop when it reaches a BOOL (char).&lt;p&gt;

Nice.&lt;p&gt;

p.s.:  the arbitrary nesting is still in the implementation, with each of the collection processing
HOMs actually running an enumerator and those enumerators stackable, and this is two of the reasons
the implementation is so gnarly:  (1) there is extra generality that is not needed and (2) making
that more general mechanism run fast was really, really tricky.&lt;p&gt;
p.p.s:  He actually discussed it almost a year ago, but I just saw it now.&lt;p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-4715721926048787685?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/4715721926048787685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=4715721926048787685' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/4715721926048787685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/4715721926048787685'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2007/11/better-hom-selects.html' title='Better HOM selects'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8397311766319215218.post-4907891978879381450</id><published>2007-10-03T11:41:00.001-07:00</published><updated>2007-10-03T11:41:56.434-07:00</updated><title type='text'>Reading Helps</title><content type='html'>&lt;a href="http://www.cincomsmalltalk.com/blog/blogView"&gt;James Robertson&lt;/a&gt; &lt;a href="http://www.cincomsmalltalk.com/blog/blogView?showComments=true&amp;printTitle=Stupidity_as_an_Ideology&amp;entry=3368786071"&gt;slams&lt;/a&gt; the proposal by the &lt;a href="http://www.globalisation.eu/blog/technology/microsoft-responds-to-our-unbundling-proposal-200709251246/"&gt;EU free market institute&lt;/a&gt; to unbundle the OS from PCs sold in the EU.
&lt;blockquote&gt;

I've seen a lot of stupid ideas float past, but &lt;a href="http://tech.blorge.com/Structure:%20/2007/09/24/globalization-institute-wants-eu-to-unbundle-windows-with-pcs/"&gt;this&lt;/a&gt; one from the EU's Globalization Institute makes it into the top 5 - only the existence of the RIAA and the MPAA prevent a complete victory for these morons:
&lt;blockquote&gt;
[..]
The think tank recommended to the EU that all computers be sold without an operating system and sees no reason "why computer operating systems could not follow the same model as computer hard drives and processors."
&lt;/blockquote&gt;
Yes, installing an OS from scratch is exactly what most buyers long to do - it's such a productive use of their time.

&lt;/blockquote&gt;

Hmmm, what could they mean with the "same model as computer hard drives and processors"?&lt;p&gt;

Well, of course!  We all buy processors and hard drives separately, mount the CPU on our separately purchased motherboard, hook up hard-drive and power-supply and stick it all in a chassis.  That *must* be what they meant with that phrase.&lt;p&gt;

Or maybe, they meant that you can configure your computer with different CPUs and hard drives, and have the vendor ship you a machine configured to your specifications, whereas you cannot actually get
a computer and not pay the Microsoft tax?   Nah, that's just *crazy*:

&lt;blockquote&gt;
IT professionals are being forced to adopt Microsoft's operating systems — even if they tell their PC supplier they want a system free of Microsoft software, ZDNet UK's research has revealed.
&lt;/blockquote&gt;

&lt;a href="http://news.zdnet.co.uk/hardware/0,1000000091,39286228,00.htm"&gt;Oh&lt;/a&gt;.&lt;p&gt;  
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8397311766319215218-4907891978879381450?l=www.metaobject.com%2Fblog' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/4907891978879381450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=8397311766319215218&amp;postID=4907891978879381450' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/4907891978879381450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8397311766319215218/posts/default/4907891978879381450'/><link rel='alternate' type='text/html' href='http://www.metaobject.com/blog/2007/10/reading-helps.html' title='Reading Helps'/><author><name>Marcel Weiher</name><uri>http://www.blogger.com/profile/11651004661887001433</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08116177601724260426'/></author><thr:total>0</thr:total></entry></feed>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  