View mode: basic / threaded / horizontal-split · Log in · Help
February 21, 2010
Re: Some questions now D2 is frozen
On 2010-02-21 08:56:14 -0500, Philippe Sigaud <philippe.sigaud@gmail.com> said:

> Anyway, I just tried:
> 
> class C {
> 
>    alias opImplicitCast this;
> 
>    @property int opImplicitCast() { return 1;}
> }
> 
> auto c = new C();
> int foo(int a) { return a;}
> 
> foo(c); // error. function main.foo (int a) is not callable using argument
> types (C)
> auto i = cast(int)c; // This works, but I'd call that explicit cast...
> 
> I'm doing something wrong there? Is calling foo on c an implicit cast?

I was using this to implicitly convert to an Object. Seems it does not 
work for an int.


-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/
February 21, 2010
Re: Some questions now D2 is frozen
On 2/21/10 14:28, Philippe Sigaud wrote:
>
>
> On Fri, Feb 19, 2010 at 13:51, Jacob Carlborg <doob@me.com
> <mailto:doob@me.com>> wrote:
> [Universal function call syntax]
>
>     It's not implemented yet.
>
>
> But do you know of it's on the plate for D2? Lars says it's in TDPL, so
> it must be on the todo list, hopefully.

Andrei said it would be in D2 but then he also said it's already 
implemented, which it isn't. It's also easy to implement (at least for 
variables).

> Well, I guess they all have too much to do right now, and as some recent
> new features are quite cool, I'm happy that way.
>
> Anyway, that would be a useful feature, particularly for generic code:
> you know some types have a method that you want to use, and you can add
> it to other types also with this mechanism.
>
>
> Another thing I'd be very happy to have is opImplicitCast....
>
> Philippe
>
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home