Support implicit conversion between types

Kapps opantm2+spam at gmail.com
Wed Sep 4 16:04:30 PDT 2013


On Wednesday, 4 September 2013 at 23:00:07 UTC, H. S. Teoh wrote:
> On Wed, Sep 04, 2013 at 02:14:26PM -0700, Ali Çehreli wrote:
>> On 09/04/2013 01:46 PM, Adam D. Ruppe wrote:
>> 
>> > D does not support implicit struct construction.
>> 
>> That's what I knew.
>> 
>> > Interestingly though, it *does* support it for functions 
>> > taking
>> > classes:
>> >
>> > class Foo {
>> >          this(int i) {}
>> > }
>> >
>> > void foo(Foo f...) {}
>> >
>> > void main() {
>> >          foo(10);
>> > }
>> 
>> WHAT? :) It even new's one?
>> 
>> But it works only for the ellipsis.
>> 
>> I wonder why the discrepancy...
> [...]
>
> Whoa. I never knew about this! It's ... I don't know what to 
> say. It
> seems to be a cool feature, but it's also ... so scary. 
> Implicit new's
> just leaves a lump in my throat. Is this an actual, intentional
> feature??!
>
>
> T

It, in theory, doesn't allocate memory:
"An implementation may construct the object or array instance on 
the stack. Therefore, it is an error to refer to that instance 
after the variadic function has returned"



More information about the Digitalmars-d-learn mailing list