Thread overview
ref locals
Aug 14
Manu
Aug 14
Marcus
Aug 14
Manu
Aug 14
Manu
August 15
This is kinda rhetorical, since I've asked this a million times, and we all know the answer... but seriously; why can't we declare ref locals?

Lots of functions return a ref; and we need to capture the result of those functions appropriately.

ref T f();

void t()
{
  ref T result = f();  // <-- there's no good reason to reject this
}

I don't understand why this doesn't come up every few days, everytime a new user appears. Is this really okay? Why does this make me feel so frustrated, but nobody else seems to care?

... "Use a pointer!" ...

void t()
{
  T* result_ptr = &f();  // seriously?
}

I feel embarrassed by this suggestion, why don't you feel embarrassed by
this suggestion?
It's also pretty shit that taking a pointer of a function's result like
that is not compatible with ufcs, where it instead attempts to create a
function pointer.

It gets worse when the function is property-like.

void t()
{
  T* prop_ptr = &myThing.prop;
}

error: cannot implicitly convert expression `& f` of type `T delegate()
ref` to `T*`

A new D user will look at that and think it's stupid... at least; I look at
that and I think it's stupid!
ref locals already please, this has gone on long enough!


August 14
On Wednesday, 14 August 2024 at 14:26:34 UTC, Manu wrote:
> This is kinda rhetorical, since I've asked this a million times, and we all know the answer... but seriously; why can't we declare ref locals?
>
> ...

The "Second Draft: ref for Variable Declarations" thread in the "DIP Devel" forum might be useful.


August 14
On Wednesday, 14 August 2024 at 15:59:16 UTC, Bruce Carneal wrote:
> On Wednesday, 14 August 2024 at 14:26:34 UTC, Manu wrote:
>> This is kinda rhetorical, since I've asked this a million times, and we all know the answer... but seriously; why can't we declare ref locals?
>>
>> ...
>
> The "Second Draft: ref for Variable Declarations" thread in the "DIP Devel" forum might be useful.

PS: I'm a fan of your work.  If you're headed to DConf I'd enjoy talking.  If not maybe DM via discord?

August 14
On Wednesday, 14 August 2024 at 14:26:34 UTC, Manu wrote:
> This is kinda rhetorical, since I've asked this a million times, and we all know the answer... but seriously; why can't we declare ref locals?

https://dlang.org/changelog/pending.html#dmd.reflocal
August 14

On Wednesday, 14 August 2024 at 20:06:49 UTC, Nick Treleaven wrote:

>

On Wednesday, 14 August 2024 at 14:26:34 UTC, Manu wrote:

>

This is kinda rhetorical, since I've asked this a million times, and we all know the answer... but seriously; why can't we declare ref locals?

https://dlang.org/changelog/pending.html#dmd.reflocal

We are so back.

August 15
OMFG, this is a truly glorious day, and what a delightful coincidence! Thank the gods for their terribly late but eventual insight!

On Thu, 15 Aug 2024 at 06:11, Nick Treleaven via Digitalmars-d < digitalmars-d@puremagic.com> wrote:

> On Wednesday, 14 August 2024 at 14:26:34 UTC, Manu wrote:
> > This is kinda rhetorical, since I've asked this a million times, and we all know the answer... but seriously; why can't we declare ref locals?
>
> https://dlang.org/changelog/pending.html#dmd.reflocal
>


August 15
On Thu, 15 Aug 2024 at 09:53, Manu <turkeyman@gmail.com> wrote:

> OMFG, this is a truly glorious day, and what a delightful coincidence! Thank the gods for their terribly late but eventual insight!
>

Is it too late to get the -preview=rvaluerefparam change into 2.111 as well? It looks like the release is running late, but that would really round the whole thing out! :P