News for hackers. Stuff that matters.
Re:Avoid Null Checks by Replacing Finders with Tellers by masklinn on Monday June 17, 2013 @01:47PM (#5894645)
> That sucks, but I can't even imagine what the processor ends up executing for the Ruby lambda callback.

That's not a very good question, `if object == nil` will already be a pretty huge number of instructions in ruby.

Now if the question is "could you have this pattern compile down to little more than a null check", the answer is why not? A bit of flattening/inlining should be able to handle it correctly.

And in most fields, the gain in safety way outweighs the almost unnoticeable (against background noise) loss in efficiency.

Re:Avoid Null Checks by Replacing Finders with Tellers by Locke1689 on Monday June 17, 2013 @01:57PM (#5894722)
could you have this pattern compile down to little more than a null check

The answer for C# and Java, which this issue was directed at, is no.

Email me if you want details.

Re:Avoid Null Checks by Replacing Finders with Tellers by masklinn on Monday June 17, 2013 @02:01PM (#5894761)
> The answer for C# and Java, which this issue was directed at, is no.

I'm not sure what you're talking about, you focused on java and C# for odd and unknown reasons, TFA merely uses java as an example of syntactically heavy (or even missing) closures language to illustrate the pattern's gains and differences.

Re:Avoid Null Checks by Replacing Finders with Tellers by Locke1689 on Monday June 17, 2013 @02:06PM (#5894797)
Did you read the article? This is the beginning of it:

The other day, I saw this example on StackOverflow:

    Person person = dataSource.getPersonById(personId);
    if (person != null) {
        person.setPhoneNumber(phoneNumber);
        dataSource.updatePerson(person);
    }
This looks like a typical case where we need a null check.

If the canonical example under discussion is in Java, I think it is safe to assume the article is about Java.

Re:Avoid Null Checks by Replacing Finders with Tellers by masklinn on Monday June 17, 2013 @03:45PM (#5895444)
> I think it is safe to assume the article is about Java.

No. The article is about a pattern of explicit null-check avoidance, java is an example of "a language without blocks or lambdas" but the article is no more about java than it is about ruby, you're not even missing the forest for the trees you're missing the forest for a fallen leaf.