auto

Ary Borenszweig ary at esperanto.org.ar
Thu Aug 13 19:29:29 PDT 2009


Jason House escribió:
> Ary Borenszweig Wrote:
> 
>> Jarrett Billingsley wrote:
>>> On Wed, Aug 12, 2009 at 9:18 AM, Ary Borenszweig<ary at esperanto.org.ar> wrote:
>>>> This compiles and runs in D2:
>>>>
>>>> --
>>>> import std.stdio;
>>>>
>>>> auto foo() {
>>>>    return 1;
>>>> }
>>>>
>>>> void main() {
>>>>    writefln("%s", foo());
>>>> }
>>>> --
>>>>
>>>> Since when a non-templated function can have its return type deduced? :)
>>> Cool.  I'm testing this and it really does seem to be non-templated.
>>> So of course, the first thing I tried was this:
>>>
>>> class A
>>> {
>>>     auto foo() { return 0; }
>>> }
>>>
>>> class B : A
>>> {
>>>     auto foo() { return 5; }
>>> }
>>>
>>> but DMD crashes.  :P
>> Now that it also works in Descent I can see it's because function 
>> overloading is treated before function return type inference, and the 
>> return types for the functions at those moments are null...
> 
> When can we look forward to Descent for D2? :)

The lexer and parser are already ported to 2.031 (the latest), and also 
everything related to that (the public AST, the formatter, the 
compile-time view, etc.). But I still need to finish porting the 
semantic analysis. 10 c files remaining. ;-)

I could release now with the lexer and parser, but sometimes there are 
null pointer exceptions and illegal state exceptions because of this 
lack of ported semantic. I advance little by little each day (or each 
"free time that I feel like making something"), maybe in some weeks or 
months I'll finish.

> 
> Also, what kind of porting issues did you have? How could it be made simpler? I'm assuming that whatever makes your work easier also helps others customizing their applications for D2.

I copied the diff of one part, saw the other part looked the same, so I 
copied the Java version insted of the C++ version (easier to port, 
because I don't have to replace "->" with "." and remove the "*" for 
pointers)... but it looked almost the same, but wasn't the same.

Anyway, it doesn't matter much if I make mistakes when porting. When I 
compile a big project like phobos, errors like that appear right away, 
and with that I know where the error is and where to look for a solution. :)



More information about the Digitalmars-d mailing list