Things that make writing a clean binding system more difficult

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 29 01:34:38 PDT 2016


On Friday, July 29, 2016 09:03:18 Timon Gehr via Digitalmars-d wrote:
> 'ref' has nothing to do with the type. This is not C++.
>
> The only thing that is inconsistent here is that 'ref' is not accepted
> on the right for function declarations.

ref may not be part of the type, but it just seems totally wrong for it to
be applying to anything else. I mean, how does it make any sense for a
_function_ to be ref or not? It may return by ref, but the function itself
is a function. It's what's going on with the return value that changes based
or ref or not.

Maybe I'm just looking at this wrong, but it seems completely bizarre to
consider the _function_ to be ref or not. It sounds like it's just a weird
biproduct of trying to make it so that ref doesn't propagate beyond the
return type or the parameter so that you can't have ref variables in
general.

I've always looked at D's ref as being essentially the same as C++'s &
except that it's not considered to be part of the type, just attached to it
in a way that doesn't propagate. The same with with in or out. I just don't
see how it even makes conceptual sense for ref to be an attribute of the
function itself.

- Jonathan M Davis



More information about the Digitalmars-d mailing list