On Friday, 30 May 2014 at 12:57:52 UTC, anonymous wrote:
It's not a cast. It's the unambiguous notation for a qualified
type. Often you can omit the parentheses. With methods you
cannot. With methods you need the parentheses to let the
compiler
know that you indeed mean the return type to be
Today I got the following compile error:
Cannot implicitly convert expression (blabla) of type
const(Type) to Type
and this is a reduced example ( also on
http://dpaste.dzfl.pl/f2f3bd921989):
module test;
import std.stdio;
class Foo {
int i = 42;
}
class MyClass {
francesco cattoglio:
And why is const(Foo) getQ so much different? (e.g: this is
an explicit cast, right?
In D the syntax for casts is cast(something)somethingElse.
Bye,
bearophile
On Friday, 30 May 2014 at 12:35:46 UTC, francesco cattoglio wrote:
class MyClass {
[...]
const (Foo) getQ () const { return _Q; } // OK
// const Foo getQ () const { return _Q; } // fails
}
[...]
I don't really understand what's going on here. Why is const
Foo getQ() wrong?
On Friday, 30 May 2014 at 12:57:52 UTC, anonymous wrote:
And why is const(Foo) getQ so much different? (e.g: this is
an explicit cast, right? Is there anything that might go
wrong?)
It's not a cast. It's the unambiguous notation for a qualified
type. Often you can omit the parentheses. With
On Friday, 30 May 2014 at 12:35:46 UTC, francesco cattoglio wrote:
Today I got the following compile error:
Cannot implicitly convert expression (blabla) of type
const(Type) to Type
and this is a reduced example ( also on
http://dpaste.dzfl.pl/f2f3bd921989):
module test;
import std.stdio;
On Friday, 30 May 2014 at 12:57:52 UTC, anonymous wrote:
The const in the front is the same as the front in the back.
... the same as the const in the back