On 21/03/12 03:47, Walter Bright wrote:
On 3/20/2012 4:39 PM, H. S. Teoh wrote:On Tue, Mar 20, 2012 at 06:58:31PM -0400, Nick Sabalausky wrote:- Type inferenceYeah I forgot about this one. Being able to write: auto veryLongNamedObject = new VeryLongNamedClass(veryLongArguments); is a big boon over C++ or Java's stuttering verbosity: VeryLongNamedClass veryLongNamedObject = new VeryLongNamedClass(veryLongArguments); Plus, it's immensely useful when dealing with Range templates... can you imagine the horrifically long typenames you'd have to type you have to explicitly specify the type of a long chain of functional expressions involving 15+ std.algorithm and std.range templates?Andrei discovered an amazing use of auto. It enables you to create variables with voldemort types "that may not be named". For example: auto foo() { struct S { ... } S s; return s; } auto x = foo(); And now x is an instance of a voldemort type! It's completely encapsulated.
That idiom is already built into the language. Anonymous nested classes don't have a name at all.
auto x = new class { ... }
