Local functions infer attributes?
Manu via Digitalmars-d
digitalmars-d at puremagic.com
Sun Sep 28 18:31:40 PDT 2014
On 29 September 2014 10:51, Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On 9/28/2014 5:38 PM, Manu via Digitalmars-d wrote:
>>
>> That said, my friend encountered one of my frequently recurring pain
>> cases himself yesterday:
>> struct S(T...)
>> {
>> void f(T args) {}
>> }
>>
>> S!(int, ref S) fail; // <-- no clean way to do this. I need this very
>> frequently, and he reached for it too, so I can't be that weird.
>
>
> S!(int, S*)
That's different.
I feel like I have to somehow justify to you guys how meta code works
in D. I have meta code that is no less than 5 layers deep. It's
complex, but at the same time, somehow surprisingly elegant and simple
(this is the nature of D I guess).
If I now assume throughout my meta "pointer means ref", then when I
actually pass a pointer in, the meta can't know if it was meant to be
a ref or not. It results in complex explicit logic to handle at almost
every point due to a loss of information.
You can't call f() with the same syntax anymore (you need an '&')
which is a static if in the meta, you can't use the S* arg in the same
meta (needs a '*') which is another static if. Assignments are
changed, and unexpected indexing mechanics appear. When implementation
logic expects and understands the distinction between pointers and
ref's, this confuses that logic. When I interface between languages
(everything I never do binds to at least C++, and in this case, also
Lua), this complicates the situation.
I can't conflate 2 things that aren't the same. It leads to a lot of
mess in a lot of places.
More information about the Digitalmars-d
mailing list