December 05, 2017
On Tuesday, December 05, 2017 22:09:12 A Guy With a Question via Digitalmars-d wrote:
> Is there actually a difference between the c style cast and
> cast(type)? Other than verbosity...

They're not the same. D's cast is not split up like C++'s casts are, but it's not exactly the same as C's cast either - e.g. like C++'s dynamic_cast, if a class to class conversion fails, you get null, which C's cast doesn't do. Also, I think that D's cast is pickier about what it will let you do, whereas C's cast is more likely to want to smash something into something else if you ask it even if it doesn't make sense. And of course, D's cast understands D stuff that doesn't even exist in C (like delegates). I don't know exactly what all of the differences are though.

Regardless, the reason for the verbosity is so that you can easily grep for casts in your code.

- Jonathan M Davis

December 05, 2017
On Tuesday, 5 December 2017 at 22:21:51 UTC, Jonathan M Davis wrote:
> On Tuesday, December 05, 2017 22:09:12 A Guy With a Question via Digitalmars-d wrote:
>> Is there actually a difference between the c style cast and
>> cast(type)? Other than verbosity...
>
> They're not the same. D's cast is not split up like C++'s casts are, but it's not exactly the same as C's cast either - e.g. like C++'s dynamic_cast, if a class to class conversion fails, you get null, which C's cast doesn't do. Also, I think that D's cast is pickier about what it will let you do, whereas C's cast is more likely to want to smash something into something else if you ask it even if it doesn't make sense. And of course, D's cast understands D stuff that doesn't even exist in C (like delegates). I don't know exactly what all of the differences are though.
>
> Regardless, the reason for the verbosity is so that you can easily grep for casts in your code.
>
> - Jonathan M Davis

That's the best reason for verbosity I've heard.
December 06, 2017
On Tuesday, 5 December 2017 at 19:13:10 UTC, A Guy With a Question wrote:
> 
> Ok, so that worked. I still have the problem with importing though:
>
> mypackage: Item
>
> seems to generate the error:
>
> "Error: undefined identifier 'Item'"
>
> Which is weird, because I'm able to bring in Array through std.container.array: Array;

mypackage.mymodule : Item;
1 2
Next ›   Last »