October 03, 2007
"Robert Fraser" <fraserofhenight@gmail.com> wrote in message news:fdvg0m$2c3e$1@digitalmars.com...
> From some experience in Perl, I can say unless(P) is slightly clearer than if(!P) and until(P) is slightly clearer than while(!P) ... in most cases. I'm not arguing it should be added to D (esp. since if there are multiple ways to express something, stuff can get confusing), but they _do_ make code just that much easier to read.
>
> On that note, I'm also a slight fan of the postfix notation for simple ifs (i.e. something like "a = b if b;" or "file.read() while file.hasMoreBytes();"), but it makes parsing a *****.

Course you also get people who think it's "cute" to do something like

while(someCondition)
{
    .....
    3 pages of code...
    .....
}
if(someOtherCondition)


October 04, 2007
Anders F Björklund wrote:
> Bill Baxter wrote:
> 
>> More annoying to me is that !in doesn't work.
> 
> What's the logical negation of a pointer, anyway ?

bool negated_pointer = !some_ptr;

Seems pretty clear to me.

--bb
October 04, 2007
On 10/4/07, Bill Baxter <dnewsgroup@billbaxter.com> wrote:
> Anders F Björklund wrote:
> > Bill Baxter wrote:
> >
> >> More annoying to me is that !in doesn't work.
> >
> > What's the logical negation of a pointer, anyway ?
>
> bool negated_pointer = !some_ptr;
>
> Seems pretty clear to me.

Technically speaking, what you've done there is implicitly cast your pointer to bool and _then_ logically negated it. Mathematically speaking, if -(-x) does not equal x then you can't call it a negation. It has to be self-inverse. Logical not has this property when applied to bools !(!x)== x.

I think this is the point that Anders was making, with some good humor thrown in. You cannot take the logical not of a pointer. You have to cast it to bool first.

Of course this is no problem. I'm just being mentioning this for the hell of it :-)

Next ›   Last »
1 2 3
Top | Discussion index | About this forum | D home