www.digitalmars.com         C & C++   DMDScript  

D - Cast syntax

reply trejkaz xaoza.net writes:
I just noticed that the C-style cast syntax has been deprecated (was trying to
compile DUI when I discovered it.)

One question though... what is the merit in replacing one hard to read cast
syntax with another, equally hard to read and on top of all unfamiliar, syntax?
That is, what does this:

cast(char *)(p + 2)

Do for me over this:

(char *) (p + 2)

?

In my opinion, a cast method is fine, but it would be far simpler to read and
write if it looked like this instead:

cast(char *, p + 2)

I'm not sure why it wasn't done this way or even if it's feasible to do it that
way, but I'm also not sure why you wouldn't fix the syntax properly if you're
going to change it at all. :-)

(I apologise if this has been brought up before but I didn't see the word 'cast'
anywhere in the message listings so I thought it might be safe to bring up.)
Jun 02 2004
next sibling parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
<trejkaz xaoza.net> escribió en el mensaje
news:c9luks$ocj$1 digitaldaemon.com
| I just noticed that the C-style cast syntax has been deprecated (was
trying to
| compile DUI when I discovered it.)
|
| One question though... what is the merit in replacing one hard to read
cast
| syntax with another, equally hard to read and on top of all unfamiliar,
syntax?
| That is, what does this:
|
| cast(char *)(p + 2)
|
| Do for me over this:
|
| (char *) (p + 2)
|
| ?

Parsing is easier.

|
| In my opinion, a cast method is fine, but it would be far simpler to read
and
| write if it looked like this instead:
|
| cast(char *, p + 2)

That's understable, yes. But if you see this:

cast(a,b);

How do you know if it's b->a or a->b?

|
| I'm not sure why it wasn't done this way or even if it's feasible to do it
that
| way, but I'm also not sure why you wouldn't fix the syntax properly if
you're
| going to change it at all. :-)
|
| (I apologise if this has been brought up before but I didn't see the word
'cast'
| anywhere in the message listings so I thought it might be safe to bring
up.)


-----------------------
Carlos Santander Bernal
Jun 03 2004
parent trejkaz xaoza.net writes:
In article <c9odo9$1bkp$2 digitaldaemon.com>, Carlos Santander B. says...
 Parsing is easier.
Well... I guess...
| In my opinion, a cast method is fine, but it would be far simpler to read
| and write if it looked like this instead:
|
| cast(char *, p + 2)

That's understable, yes. But if you see this:

cast(a,b);

How do you know if it's b->a or a->b?
The same way that you know which one it is when you write cast()()! TX
Jun 06 2004
prev sibling parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
You're posting on the wrong newsgroup. This one's been retired.

But the answer is that you can grep for cast with ease. It's pretty hard to grep
for casts in and amongst all the other braces.

<trejkaz xaoza.net> wrote in message news:c9luks$ocj$1 digitaldaemon.com...
 I just noticed that the C-style cast syntax has been deprecated (was trying to
 compile DUI when I discovered it.)

 One question though... what is the merit in replacing one hard to read cast
 syntax with another, equally hard to read and on top of all unfamiliar, syntax?
 That is, what does this:

 cast(char *)(p + 2)

 Do for me over this:

 (char *) (p + 2)

 ?

 In my opinion, a cast method is fine, but it would be far simpler to read and
 write if it looked like this instead:

 cast(char *, p + 2)

 I'm not sure why it wasn't done this way or even if it's feasible to do it that
 way, but I'm also not sure why you wouldn't fix the syntax properly if you're
 going to change it at all. :-)

 (I apologise if this has been brought up before but I didn't see the word
'cast'
 anywhere in the message listings so I thought it might be safe to bring up.)
Jun 05 2004