www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - bug?

reply novice <novice_member pathlink.com> writes:
void main()
{
ubyte k;
ubyte a,b,c;
k = 0x13;
a = (k>>2) & 0x01;
b = (k>>1) & 0x01;

/*
Next line of code give compile error.
Digital Mars D Compiler v0.102 say:
"C style cast deprecated, use cast(k)(#1)"
Digital Mars D Compiler older sav:
"'1' is not an lvalue"
*/
c = (k   ) & 0x01;  


/*
Next line give no errors
*/
c =  k     & 0x01;
}
Sep 23 2004
next sibling parent reply Derek Parnell <derek psych.ward> writes:
On Fri, 24 Sep 2004 05:06:31 +0000 (UTC), novice wrote:

 void main()
 {
 ubyte k;
 ubyte a,b,c;
 k = 0x13;
 a = (k>>2) & 0x01;
 b = (k>>1) & 0x01;
 
 /*
 Next line of code give compile error.
 Digital Mars D Compiler v0.102 say:
 "C style cast deprecated, use cast(k)(#1)"
 Digital Mars D Compiler older sav:
 "'1' is not an lvalue"
 */
 c = (k   ) & 0x01;  

This is to be expected. This is because "(k)" is ambiguous. It could be an identifier enclosed in parenthesis or it could be a C-language style cast. The preferred solutions include ... c = k & 0x01; // probably the best one c = (k>>0) & 0x01; // but this fits the pattern c = (k+0) & 0x01; // this emphasizes the expression nature an alternate solution is to add the -d command line switch that allows depreciated code formats. -- Derek Melbourne, Australia 24/Sep/04 3:08:01 PM
Sep 23 2004
parent reply Stewart Gordon <Stewart_member pathlink.com> writes:
In article <cj0ace$2k9f$1 digitaldaemon.com>, Derek Parnell says...

<snip>
 Next line of code give compile error.
 Digital Mars D Compiler v0.102 say:
 "C style cast deprecated, use cast(k)(#1)"


 an alternate solution is to add the -d command line switch that 
 allows depreciated code formats.

Deprecated, not depreciated. Depreciated means lowered in value. AIUI the -d switch doesn't affect the parsing at all. So it will equally try to do the same: take the address of 0x01, and cast it to a k, both of which are meaningless. If it did have an effect on parsing, then _omitting_ -d would cause it to interpret as was meant. Stewart.
Sep 24 2004
parent reply Sha Chancellor <schancel pacific.net> writes:
In article <cj0nv7$2smn$1 digitaldaemon.com>,
 Stewart Gordon <Stewart_member pathlink.com> wrote:

 Deprecated, not depreciated.  Depreciated means lowered in value.

I really dislike it when people go around correcting other people's english, on a programming forum no less. Even on the issue of deprecated vs depreciated. What are you, an english teacher? The way you're using deprecated is fabricated anyways. See: http://www.worldwidewords.org/topicalwords/tw-dep1.htm He wrote what he did because of how he viewed that which he wrote of. Both the perceptions of depreciated, and deprecated, would be acceptable to me. If you would consider a moment what he wrote, instead of what you think he should have wrote, you would see that. As in: A c-style cast is deprecated, meaning they're disapproved of now that we have D-style casts. A c-style cast is depreciated, meaning they're not as useful, or of a lesser value, now that we have D-style casts. There's more than one way to skin a cat. -Sha
Sep 25 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
Sha Chancellor wrote:
 In article <cj0nv7$2smn$1 digitaldaemon.com>,
  Stewart Gordon <Stewart_member pathlink.com> wrote:
 
 
Deprecated, not depreciated.  Depreciated means lowered in value.

I really dislike it when people go around correcting other people's english, on a programming forum no less. Even on the issue of deprecated vs depreciated. What are you, an english teacher?

So what if he is. I invite all English teachers to post here. I think this group could benefit from some language tips.
 
 The way you're using deprecated is fabricated anyways. See: 
 http://www.worldwidewords.org/topicalwords/tw-dep1.htm

Apparently, the dictionary won't back me up on this (http://dictionary.reference.com/search?q=deprecated), but I think the D-land definition of deprecated is "the old way that is frowned upon". In other words, if you find deprecated code, you should change it to remove the deprecated features.
 
 He wrote what he did because of how he viewed that which he wrote of. 
 Both the perceptions of depreciated, and deprecated, would be acceptable 
 to me.  If you would consider a moment what he wrote, instead of what 
 you think he should have wrote, you would see that.

I think he was trying to be helpful. I'm willing to give him the benefit of the doubt.
 
 As in:
 
 A c-style cast is deprecated, meaning they're disapproved of now that we 
 have D-style casts.
 
 A c-style cast is depreciated, meaning they're not as useful, or of a 
 lesser value, now that we have D-style casts.

IMHO, that's a gross understatement with regards to C-style cast. I've got the impression that evenually support of C-style casts will be completely dropped. Currently, one has to compile with a special flag if it's even going to work.
 
 There's more than one way to skin a cat.

There are multiple methods, but some will be much more effective than others.
 
 
 -Sha

-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Sep 25 2004
parent reply Nigel Sandever <nigelsandever btconnect.com> writes:
On Sat, 25 Sep 2004 11:15:49 -0500, J C Calvarese <jcc7 cox.net> wrote:
 Sha Chancellor wrote:
 In article <cj0nv7$2smn$1 digitaldaemon.com>,
  Stewart Gordon <Stewart_member pathlink.com> wrote:
 
 There's more than one way to skin a cat.

There are multiple methods, but some will be much more effective than others.

If the cat ends up skinless by each method, each method is equally effective. There may be some question as to one method being more efficent than another, but the effectiveness is not questionable if the desired outcome is achieved. If the desired outcome is not achievable by the attempted means of achievement: It is not a method. Pedantists unight! :)
 
 
 
 -Sha

-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/

Sep 25 2004
parent J C Calvarese <jcc7 cox.net> writes:
Nigel Sandever wrote:

 On Sat, 25 Sep 2004 11:15:49 -0500, J C Calvarese <jcc7 cox.net> wrote:
 
Sha Chancellor wrote:

In article <cj0nv7$2smn$1 digitaldaemon.com>,
 Stewart Gordon <Stewart_member pathlink.com> wrote:

There's more than one way to skin a cat.

There are multiple methods, but some will be much more effective than others.

If the cat ends up skinless by each method, each method is equally effective. There may be some question as to one method being more efficent than another, but the effectiveness is not questionable if the desired outcome is achieved. If the desired outcome is not achievable by the attempted means of achievement: It is not a method. Pedantists unight! :)

Aaaaaaaarrrrrggggg! Foiled again! ;)
 
 
-Sha

-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/


-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Sep 25 2004
prev sibling parent Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
I believe that this is a bug, so I'm copying to the bugs newsgroup.

novice wrote:
 void main()
 {
 ubyte k;
 ubyte a,b,c;
 k = 0x13;
 a = (k>>2) & 0x01;
 b = (k>>1) & 0x01;
 
 /*
 Next line of code give compile error.
 Digital Mars D Compiler v0.102 say:
 "C style cast deprecated, use cast(k)(#1)"
 Digital Mars D Compiler older sav:
 "'1' is not an lvalue"
 */
 c = (k   ) & 0x01;  
 
 
 /*
 Next line give no errors
 */
 c =  k     & 0x01;
 }
 
 

Sep 24 2004