auto*

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 6 16:12:03 PDT 2017


On Thu, Jul 06, 2017 at 10:31:10PM +0000, Meta via Digitalmars-d wrote:
> On Thursday, 6 July 2017 at 21:58:45 UTC, H. S. Teoh wrote:
> > On Thu, Jul 06, 2017 at 09:42:22PM +0000, Meta via Digitalmars-d wrote:
> > > On Thursday, 6 July 2017 at 18:10:57 UTC, FoxyBrown wrote:
> > > > Create an auto pointer, handy in some cases and fits in the
> > > > language as a natural generalization.
> > > 
> > > It's been suggested before (as well as more powerful
> > > generalization for slices and associative arrays), but Andrei
> > > vetoed it so it probably won't be added even if somebody created a
> > > formal proposal for it.
> > 
> > I'm curious, what exactly was proposed?  Because I have a hard time
> > understanding what's intended from the OP's description.
> > 
> > 
> > T
> 
> Partial type inference. `auto*` declares a point to a type that is
> inferred from inspecting the RHS's type. The previous proposal was for
> doing `auto[] a = [0, 1, 2]` (a's type is inferred as int[]).

But doesn't `auto a = [0, 1, 2];` *already* infer typeof(a) as int[]?
What does `auto[]` add over what `auto` already does?


T

-- 
"Real programmers can write assembly code in any language. :-)" -- Larry Wall


More information about the Digitalmars-d mailing list