July 24, 2006
Andrei Khropov wrote:
> And what about double meaning of 'auto'?
> 
> It's a longstanding issue and changes could break lots of code, but I think it's
> a terrible design inconsistency.
> 
> And it also currently means that we cannot use type inference with auto classes
> (which is also inconsistensy by itself)
> 
> ------------------------------------------------
> import std.stdio;
> 
> auto class X
> {
> public:
>     int _i;
>         this(int i1)
>     {
>         _i = i1;
>     }
>         int i()
>     {
>         return _i;
>     }
>         ~this()
>     {
>       writefln("destructor i=",_i);     }
> }
> 
> void main()
> {
>     auto X x1 = new X(1);
>         //auto auto x2 = new X(2); // auto1.d(28): redundant storage class 'auto'
>         // auto x3 = new X(3); // auto1.d(30): variable auto1.main.x3 reference to
> auto class must be auto
>         writefln("x1.i=",x1.i);
>     //writefln("x2.i=",x2.i);
>     //writefln("x3.i=",x3.i);
> }
> ---------------------------------------------------
> 
> Some discussion was here: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/38443
> 
> (I personally vote for 'var' for type inference)

You have my vote too.


> 
July 24, 2006
On Sat, 22 Jul 2006 00:30:35 -0700, Walter Bright wrote:

> I think the title says it all.

There are still areas in the official documentation marked as "TBD", and so I guess these should be done before announcing it to the (critical) world at large.

-- 
Derek Parnell
Melbourne, Australia
"Down with mediocrity!"
July 24, 2006
On Mon, 24 Jul 2006 00:33:23 +0000 (UTC), Andrei Khropov wrote:

> And what about double meaning of 'auto'?

In general 'auto' is a poor choice for both meanings. 'auto' is obviously shorthand for automatic, but automatic what???

Walter, given that 'auto' as a keyword is not going to be removed from the language, how can one currently declare a type-inferred variable that has RAII properties?

-- 
Derek Parnell
Melbourne, Australia
"Down with mediocrity!"
July 24, 2006
On Mon, 24 Jul 2006 06:58:39 -0700, Sean Kelly <sean@f4.ca> wrote:
> Chris Nicholson-Sauls wrote:
>>  And I believe this is what is used in the new edition of C# for type inference, yes?
>
> Yes, though 'auto' will be used for type inference in C++.  Personally, I'd prefer scoped destruction to use a keyword such as 'local' or 'scoped' than to change the keyword used for type inference.

I'd prefer scoped destruction to simply omit the 'new' keyword, eg.

class A {}

A a = new A(); //normal
A a = A(); //destroyed at end of scope

and with auto..

auto a = new A(); //normal
auto a = A(); //destroyed at end of scope

Simple, elegant, obvious (IMO)

Regan
July 24, 2006
Regan Heath wrote:
> On Mon, 24 Jul 2006 06:58:39 -0700, Sean Kelly <sean@f4.ca> wrote:
>> Chris Nicholson-Sauls wrote:
>>>  And I believe this is what is used in the new edition of C# for type inference, yes?
>>
>> Yes, though 'auto' will be used for type inference in C++.  Personally, I'd prefer scoped destruction to use a keyword such as 'local' or 'scoped' than to change the keyword used for type inference.
> 
> I'd prefer scoped destruction to simply omit the 'new' keyword, eg.
> 
> class A {}
> 
> A a = new A(); //normal
> A a = A(); //destroyed at end of scope
> 
> and with auto..
> 
> auto a = new A(); //normal
> auto a = A(); //destroyed at end of scope
> 
> Simple, elegant, obvious (IMO)

I like this too, though it doesn't address being able to label a class as 'auto'.  But perhaps that syntax can stay as-is?


Sean
July 24, 2006
Sean Kelly wrote:
> Regan Heath wrote:
>> On Mon, 24 Jul 2006 06:58:39 -0700, Sean Kelly <sean@f4.ca> wrote:
>>> Chris Nicholson-Sauls wrote:
>>>>  And I believe this is what is used in the new edition of C# for type inference, yes?
>>>
>>> Yes, though 'auto' will be used for type inference in C++.  Personally, I'd prefer scoped destruction to use a keyword such as 'local' or 'scoped' than to change the keyword used for type inference.
>>
>> I'd prefer scoped destruction to simply omit the 'new' keyword, eg.
>>
>> class A {}
>>
>> A a = new A(); //normal
>> A a = A(); //destroyed at end of scope
>>
>> and with auto..
>>
>> auto a = new A(); //normal
>> auto a = A(); //destroyed at end of scope
>>
>> Simple, elegant, obvious (IMO)
> 

So do I.

> I like this too, though it doesn't address being able to label a class as 'auto'.  But perhaps that syntax can stay as-is?
> 

I think so too.

> 
> Sean
July 24, 2006
On Mon, 24 Jul 2006 17:48:52 -0500, Dave <Dave_member@pathlink.com> wrote:
> Sean Kelly wrote:
>> Regan Heath wrote:
>>> On Mon, 24 Jul 2006 06:58:39 -0700, Sean Kelly <sean@f4.ca> wrote:
>>>> Chris Nicholson-Sauls wrote:
>>>>>  And I believe this is what is used in the new edition of C# for type inference, yes?
>>>>
>>>> Yes, though 'auto' will be used for type inference in C++.  Personally, I'd prefer scoped destruction to use a keyword such as 'local' or 'scoped' than to change the keyword used for type inference.
>>>
>>> I'd prefer scoped destruction to simply omit the 'new' keyword, eg.
>>>
>>> class A {}
>>>
>>> A a = new A(); //normal
>>> A a = A(); //destroyed at end of scope
>>>
>>> and with auto..
>>>
>>> auto a = new A(); //normal
>>> auto a = A(); //destroyed at end of scope
>>>
>>> Simple, elegant, obvious (IMO)
>>
>
> So do I.
>
>> I like this too, though it doesn't address being able to label a class as 'auto'.  But perhaps that syntax can stay as-is?
>
> I think so too.

Or the keyword can be changed to something else. I have to admit I've never really liked this usage of auto, it places restrictions on my usage of the class.. I prefer to have full control over how I use them, even if it means I might forget.

Regan
July 24, 2006
Regan Heath wrote:
> On Mon, 24 Jul 2006 17:48:52 -0500, Dave <Dave_member@pathlink.com> wrote:
>> Sean Kelly wrote:
>>> Regan Heath wrote:
>>>> On Mon, 24 Jul 2006 06:58:39 -0700, Sean Kelly <sean@f4.ca> wrote:
>>>>> Chris Nicholson-Sauls wrote:
>>>>>>  And I believe this is what is used in the new edition of C# for type inference, yes?
>>>>>
>>>>> Yes, though 'auto' will be used for type inference in C++.  Personally, I'd prefer scoped destruction to use a keyword such as 'local' or 'scoped' than to change the keyword used for type inference.
>>>>
>>>> I'd prefer scoped destruction to simply omit the 'new' keyword, eg.
>>>>
>>>> class A {}
>>>>
>>>> A a = new A(); //normal
>>>> A a = A(); //destroyed at end of scope
>>>>
>>>> and with auto..
>>>>
>>>> auto a = new A(); //normal
>>>> auto a = A(); //destroyed at end of scope
>>>>
>>>> Simple, elegant, obvious (IMO)
>>>
>>
>> So do I.
>>
>>> I like this too, though it doesn't address being able to label a class as 'auto'.  But perhaps that syntax can stay as-is?
>>
>> I think so too.
> 
> Or the keyword can be changed to something else. I have to admit I've never really liked this usage of auto, it places restrictions on my usage of the class.. I prefer to have full control over how I use them, even if it means I might forget.
> 
> Regan

Heck, I don't care if it stays 'auto class ...' or not unless that makes it more likely for the first idea to be implemented :)

The problem I can see with 'A a = A()' would be that people would expect it to be stack allocated (and that's never going to happen for v1.0) but it is still my preference over the long haul so I'd live with it.

Auto type inference and auto dtors are both great features and it's a shame if they couldn't be used together, though personally I don't think this should hold v1.0 up because there is a simple workaround.
July 25, 2006
Regan Heath wrote:

> I'd prefer scoped destruction to simply omit the 'new' keyword, eg.
> 
> class A {}
> 
> A a = new A(); //normal
> A a = A(); //destroyed at end of scope
> 
> and with auto..
> 
> auto a = new A(); //normal
> auto a = A(); //destroyed at end of scope
> 
> Simple, elegant, obvious (IMO)
> 
> Regan

Well, it may be a solution, but I personally regard 'new' as a visual cue that indicates that memory is allocated from the heap.

But considering your proposal we should get rid of 'auto class' too,
because 'auto' should mean only one thing - be it scope lived classes or type
inference.

I think it's easier to change type inference syntax since it's a relatively recent addition and hence it'll break less code.

-- 
AKhropov
July 25, 2006
Derek wrote:
> On Mon, 24 Jul 2006 00:33:23 +0000 (UTC), Andrei Khropov wrote:
> 
>> And what about double meaning of 'auto'?
> 
> In general 'auto' is a poor choice for both meanings. 'auto' is obviously
> shorthand for automatic, but automatic what??? 
> 
> Walter, given that 'auto' as a keyword is not going to be removed from the
> language, how can one currently declare a type-inferred variable that has
> RAII properties?
> 

Regan Heath penned the solution I thought I'd posted a while back, but maybe I hadn't:

> class A {}
> 
> A a = new A(); //normal
> A a = A(); //destroyed at end of scope
> 
> and with auto..
> 
> auto a = new A(); //normal
> auto a = A(); //destroyed at end of scope
> 
> Simple, elegant, obvious (IMO)