DMD 0.148 release

Derek Parnell derek at psych.ward
Sun Feb 26 15:09:19 PST 2006


On Mon, 27 Feb 2006 00:17:12 +0200, Georg Wrede wrote:

> Derek Parnell wrote:
>> On Mon, 27 Feb 2006 06:05:13 +1100, Georg Wrede <georg at nospam.org> wrote:
> 
>>> We've all had our fights with C, C++, and other related languages. 
>>> But  honestly, how many of us can confess to having problems with 
>>> logical  values?
>> 
>> Me.
>> 
>>> And if someone here has such problems, I suggest switching to VB.
>> 
>> I am also a VB coder and I'm not a language bigot.
> 
> Oh. I'm sorry. I'll try not to mention VB in the future.

That's okay, you don't have to be embarrassed amongst friends. There are
still a lot of people that regard BASIC, and VB in particular, as 'not real
programming languages'. 
 
> ---
> 
> I think we've gotten it backwards here, so let's turn the table:
> 
> Can you give some example code and use cases where we absolutely need 
> your kind of booleans?

Imagine that someone wrote a library function that reads a text file in and
returns the number of lines read in. You know that a file with less than 3
lines is invalid, so you write ...

   int cnt = read_text(filename);
   if (cnt < 3)
         throw new Exception(...);

However, later on the library is updated and now returns a boolean: true if
successful, and false otherwise. Your programs will still compile but it
shouldn't. And it will always fail at run time even if the file read in
contained three or more lines.

However, if we had a true boolean semantics, the compiler would display an
error instead of you getting a run time error.

To point is that a language that implemented boolean semantics could help
eliminate a set of coding errors that D's 'bool' will not catch. In the
same way that 'real' and 'int' are used to catch such errors.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
27/02/2006 9:58:09 AM



More information about the Digitalmars-d-announce mailing list