DMD 0.149 release
Derek Parnell
derek at psych.ward
Tue Mar 7 17:31:21 PST 2006
On Wed, 08 Mar 2006 02:47:38 +0200, Georg Wrede wrote:
> Jarrett Billingsley wrote:
>> "Georg Wrede" <georg.wrede at nospam.org> wrote in message
>> news:440E1336.3050608 at nospam.org...
>>
>>>BTW, what does "Implicit casts of non-bool to bool disallowed" mean?
>>
>> It means you can no longer write
>>
>> bool x = 5;
>
> Shhhhhttt! Good-bye C/C++ folks!
>
> It's not like anybody would want to write exactly
>
> bool x = 5;
>
> but more like
>
> bool x = strcmp("foo", "bar");
> if (!x) { /* do stuff */ } // match
> else { /* call the cops! */ } // no match
Why would anyone in their right mind code something as stupid as that? This
just misleads people who have to read your code. Instead do either ...
bool x = cast(bool)strcmp("foo", "bar");
or
int x = strcmp("foo", "bar");
or
auto x = strcmp("foo", "bar");
In other words, code what you mean and mean what you code.
> which, incidentally, is one of the more profound proposititions in any
> C-derived language.
Profoundly dumb. <g>
> The Old School Boolean C Logic was a perfectly functioning Concept. This
> fact _alone_ was the reason "Bool" took so long to be "formally"
> introduced into either C or C++. No regular programmer ever needed Prude
> Bool, only the Superior Theoreticians Thought it Wise to force this upon
> the language. It was profoundly useful as-is, and didn't need any
> pimping.
Are you deliberately trolling?
I am a "regular programmer" and a correctly implemented boolean type is
exactly what I need. What on Earth is "profoundly useful" about assigning a
number to a boolean variable? It is far better (read: cost efficient at
compile time, run time, and maintenance time) to code your intentions
rather than taking advantage of a language's quirky 'features'. Such
behaviour is only (IMNSHO) acceptable in absolutely runtime performance
critical fragments, and then only if heavily and accurately documented.
> A language that purports to be "to-the-metal" just has to take
> into consideration the fundamentals of [digital] life. And processor
> physics. (Wanna abstract away that? Then go to Java or whatever.)
You seem to be confusing implementation with syntax/semantics. The compiler
can do the semantic analysis correctly and then implement the code in the
most efficient manner for the target platform. These are independent of
each other.
> The other night [in the D newsgroup, when it was getting hilarious] it
> dawned to me, that quite [too] many of the vocatious NG-members never
> had read their Boolean IT Fundamentals.
And yet, you don't seem to "get it" either.
> Good Grief: "there's just too many instances in history where the
> illiterati have dictated the outcome of otherwise intellectual
> confrontations". Damn!!
>
> The ramifications of this (minor looking) modification are grave, I'm
> afraid.
>
> Now what happens to
>
> if (stcmp("foo", "bar")) {}
>
> ???
This really shows that you are reading too much into the issue and not
reading the specs themselves. In fact, a 2-minute test would answer this
question for you anyway!
import std.stdio;
int Foo(int x)
{
return x;
}
void main()
{
bool x = cast(bool)Foo(0);
if (!x) { writefln(" do stuff "); }
else { writefln("call the cops!"); }
if(Foo(2)) writefln("Foo(2)");
if(Foo(0)) writefln("Foo(0)");
}
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
8/03/2006 12:14:18 PM
More information about the Digitalmars-d-announce
mailing list