On Thursday, 6 July 2017 at 23:12:03 UTC, H. S. Teoh wrote:
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
It does, but I think it's more a thing of knowing what exactly
the auto is.
Let's say you have.
auto a = foo();
You have no idea what auto actually is in that case, but
auto* a = foo();
You know auto is a pointer of whatever foo returns.