In my previous post on Loop Abstractions in D I showed you how we could make loop constructs abstract, in a similar way which is common in Ruby. The example I used as a model was the retryable method from Cheah Chu Yeow. His version is customizable in a way that let you define the type of exception that triggers a retry.
retryable(:tries => 5, :on => OpenURI::HTTPError ) do
# retryable code goes here
end
To mimic that in D we had to use templates, which are invoked with a special syntax.
retryable !(HTTPError) ({
// Retryable code goes here
}, 5);
To be honest, I don’t like the template syntax. I don’t know why, it just doesn’t feel right. If possible, I’d much prefer a more native looking code. Maybe something like this:
retryable({
// Retryable code goes here
} , 5, HTTPError );
Christopher Wright points out an implementation that would be the closest one could get to a signature like that. He uses the some...
Content suppressed by ://URLFAN, for full article visit source
The Open-Closure-Close Idiom in DFrom: feeds.feedburner.com
Post Date: 2008-02-13 05:22:26
In a Reddit discussion following my last post on object lifetime management in D , bonzinip wondered why the D closures aren’t used with the open-closure-close idiom that is common, for instance, in Ruby.
bonzinip: languages with closures (Ruby, Smalltalk) use them to ensure that the file is closed when you get out of scope, and that does not require new keywords and does not require to bypass GC and possibly get dangling pointers.
NovaProspekt: D actually has full closures...
more Managing Object Lifetimes in DFrom: feeds.feedburner.com
Post Date: 2008-02-07 05:53:33
The D Programming Language is a modern version of C. It adds productivity features to the performance power of C, features like object oriented programming and garbage collection.
It may seem strange that a language with focus on performance utilizes automatic memory management. A GC equals overhead, right? Well, actually that is a common misconception . These days implicitly memory managed code is generally faster than code where the programmer handles deallocations. One reason for this cou...
more The Most Essential Development ProblemFrom: feeds.feedburner.com
Post Date: 2008-01-25 08:14:08
Paul W. Homer has a post up discussing essential development problems . While this is a huge subject (somewhat reflected by the size Paul’s article,) I’d like to emphasize one of the things he touches: the lack of understanding the users’ problem domain.
The biggest problem in most systems today is the total failure of the programmers to have any empathy for their users.
I too have a similar perception, and I have many times been guilty as charged, although I’ve come to rea...
more