View mode: basic / threaded / horizontal-split · Log in · Help
March 08, 2006
Re: DMD 0.149 release (on bools)
On Tue, 07 Mar 2006 18:12:41 -0800, BCS wrote:

>> 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
>> 
> 
> "!!" ends up as a cast to bool
> 
> try:
> 
> import std.stdio;
> 
> int main()
> {
> 	int i = 1;
> 	int j = 2;
> 	int k = 0;
> 
> 	if(!!i)writef("i\n");else writef("!i\n");
> 	if(!!j)writef("j\n");else writef("!j\n");
> 	if(!!k)writef("k\n");else writef("!k\n");
> 
> 	return 0;
> }

LOL.... try this too.

      writefln("%s %s", !!i, !!k);

I get "true false" in return.

Now this qualifies as a real D-Geek operator.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
8/03/2006 1:15:38 PM
March 08, 2006
Re: DMD 0.149 release (on bools)
Derek Parnell wrote:
> On Tue, 07 Mar 2006 18:12:41 -0800, BCS wrote:
> 
> 
>>>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
>>>
>>
>>"!!" ends up as a cast to bool
>>
>>try:
>>
>>import std.stdio;
>>
>>int main()
>>{
>>	int i = 1;
>>	int j = 2;
>>	int k = 0;
>>
>>	if(!!i)writef("i\n");else writef("!i\n");
>>	if(!!j)writef("j\n");else writef("!j\n");
>>	if(!!k)writef("k\n");else writef("!k\n");
>>
>>	return 0;
>>}
> 
> 
> LOL.... try this too.
> 
>        writefln("%s %s", !!i, !!k);
> 
> I get "true false" in return.
> 
> Now this qualifies as a real D-Geek operator.
> 

ack! this is wrong!!

apparently, ! returns a bool
March 08, 2006
Re: DMD 0.149 release
On Tue, 07 Mar 2006 15:41:28 -0800, Sean Kelly wrote:

> Walter Bright wrote:
>> Changed on_scope keywords per the general consensus of the n.g.
>> 
>> The implicit function template instantiation is a bit limited at the moment, 
>> deduction won't work for types derived from templates, and the mechanism to 
>> pick the most specialized template doesn't work.
> 
> Could you clarify this:
> 
> "& | ^ &= |= ^= ! && || ?: are now only operators allowed on bools"
> 
> Did you mean "are now _the_ only operators allowed on bools?" 

It seems that arithmetic operators also work on booleans so I guess the
operator list above is either not correct or this is a bug.

   auto q = true + true + true;
   writefln("%s %s", true + true + true, q);

gives 
  "3 3"

but I was expecting that the form "<expression> <arithmetic-op>
<expression>" where either <expression> is a boolean result would be a
syntax error. Instead, it seems to be implicitly casting the boolean to an
int before the operation is examined.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
8/03/2006 1:36:18 PM
March 08, 2006
Re: DMD 0.149 release (on bools)
Derek Parnell wrote:
> On Tue, 07 Mar 2006 18:12:41 -0800, BCS wrote:
> 
> 
>>>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
>>>
>>
>>"!!" ends up as a cast to bool
>>
>>try:
>>
>>import std.stdio;
>>
>>int main()
>>{
>>	int i = 1;
>>	int j = 2;
>>	int k = 0;
>>
>>	if(!!i)writef("i\n");else writef("!i\n");
>>	if(!!j)writef("j\n");else writef("!j\n");
>>	if(!!k)writef("k\n");else writef("!k\n");
>>
>>	return 0;
>>}
> 
> 
> LOL.... try this too.
> 
>        writefln("%s %s", !!i, !!k);
> 
> I get "true false" in return.
> 
> Now this qualifies as a real D-Geek operator.
> 

This is an old C idiom.
March 08, 2006
Re: DMD 0.149 release
"Derek Parnell" <derek@psych.ward> wrote in message 
news:1o1ukrzuobjw5$.19cyl0ofx7fqs$.dlg@40tude.net...
> It seems that arithmetic operators also work on booleans so I guess the
> operator list above is either not correct or this is a bug.

It's a bug. Sigh. It always takes me two tries to get this right :-(
March 08, 2006
Re: DMD 0.149 release
"Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message 
news:dulcil$86q$1@digitaldaemon.com...
> And if they give up on a language because of one new feature, they don't 
> deserve to be using it.

My general experience with people who say "D is a great language, but I 
won't use it because of <minor nitpick> because <minor nitpick> is the most 
important thing in the world" is that they won't use it anyway, and are just 
looking for an excuse.
March 08, 2006
Re: DMD 0.149 release
"Lucas Goss" <lgoss007@gmail.com> wrote in message 
news:dulcq5$8cj$1@digitaldaemon.com...
> Walter Bright wrote:
>> Changed on_scope keywords per the general consensus of the n.g.
>
> nooooooooooooooooooooooooo... I guess I was the only one that didn't like 
> the proposed change of scope(...). Inconsistencies in d drive me mad 
> (crazy). I love the language and hate it at the same time.

LOL. I can't please everybody <g>.
March 08, 2006
Re: DMD 0.149 release
"BCS" <BCS_member@pathlink.com> wrote in message 
news:dule2p$5tn$1@digitaldaemon.com...
> Quote from change log:
> Added std.c.fenv.
>
> Where's the documentation? Then again where's the documentation for most 
> of std.c.*?

I haven't bothered because it will be, by definition, identical to standard 
C documentation for those declarations.
March 08, 2006
Re: DMD 0.149 release
Walter Bright wrote:
> "Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message 
> news:dulcil$86q$1@digitaldaemon.com...
>> And if they give up on a language because of one new feature, they don't 
>> deserve to be using it.
> 
> My general experience with people who say "D is a great language, but I 
> won't use it because of <minor nitpick> because <minor nitpick> is the most 
> important thing in the world" is that they won't use it anyway, and are just 
> looking for an excuse. 
> 
> 
Thats true, but its not exactly what I meant.

I mean that its still adding corner cases to a simple construct.  Corner 
cases make C++ the headache it is, but I am sure that each addition 
looked really small at the time.

Ironically the declaration-in-for-statement is not really that important 
in D thanks to foreach.

Its trivial though so I will withdraw my complaint.

Cheers.
-DavidM
March 08, 2006
Re: DMD 0.149 release
On Tue, 7 Mar 2006, Walter Bright wrote:

> Changed on_scope keywords per the general consensus of the n.g.
> 
> The implicit function template instantiation is a bit limited at the moment, 
> deduction won't work for types derived from templates, and the mechanism to 
> pick the most specialized template doesn't work.
> 
> http://www.digitalmars.com/d/changelog.html

For those that don't routinely read digitalmars.D.bugs, please use 
http://d.puremagic.com/bugzilla/ to report issues.  All new bugs and bug 
correspondence is forwarded to .bugs automatically.  See .bugs for more 
discussion on the tracking system.

Later,
Brad
1 2 3 4 5 6 7 8
Top | Discussion index | About this forum | D home