Consistency, Templates, Constructors, and D3
Tommi
tommitissari at hotmail.com
Sat Aug 25 17:07:56 PDT 2012
On Friday, 24 August 2012 at 05:14:39 UTC, F i L wrote:
> To start, let's look at: cast(T) vs to!T(t)
>
> In D, we have one way to use template function, and then we
> have special keyword syntax which doesn't follow the same
> syntactical rules. Here, cast looks like the 'scope()' or
> 'debug' statement, which should be followed by a body of code,
> but it works like a function which takes in the following
> argument and returns the result. Setting aside the "func!()()"
> syntax for a moment, what cast should look like in D is:
>
> int i = cast!int(myLong);
I agree that cast!int(myLong) looks better and more consistent
than cast(int)myLong. But I think your proposed syntax
improvement fails when you're casting to const or immutable:
cast(const)myArray --> cast!const(myArray)
Then it looks like we're passing a keyword as a template argument.
More information about the Digitalmars-d
mailing list