Carmack about static analysis

Jacob Carlborg doob at me.com
Sun Dec 25 06:03:40 PST 2011


On 2011-12-25 05:44, Andrei Alexandrescu wrote:
> On 12/24/2011 07:20 PM, Adam D. Ruppe wrote:
>> On Saturday, 24 December 2011 at 23:51:57 UTC, bearophile wrote:
>>> Using certain abstractions sometimes helps to write one idea only once
>>> in a program. Etc.
>>
>> This is the biggest one, and applies to all kinds of code.
>> I like to write little functions with meaningful names.
>>
>> bool isOdd(int i) {
>> if((i % 2) == 0)
>> return false;
>> else
>> return true;
>> }
>>
>> filter!isOdd(myCollection);
>>
>>
>> I find that nicer than
>>
>> filter!"i % 2 != 0"(myCollection);
>>
>> despite it being longer.
>
> Different strokes for different folks. IMHO it would be difficult to
> justify the verboseness and the unnecessary (twice) flow of control. I
> see every letter beyond this as a liability:
>
> bool isOdd(int i)
> {
> return (i & 1) != 0;
> }

The point was not how to implement "isOdd", it was to use a symbol instead.

>> With the former, it says very simply that it wants odd
>> numbers at the usage location.
>
> Giving an operation, however trivial, a symbol, is often a good thing.
> There are of course limits, and each engineer has their own ideas where
> to draw the line.
>
>
> Andrei


-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list