isCallable fails
frame
frame86 at live.com
Fri Jan 22 07:25:15 UTC 2021
On Friday, 22 January 2021 at 03:40:40 UTC, tsbockman wrote:
> Cars are mass-produced copies of a relatively small number of
> rather similar designs, and mechanics' customers *pay them* to
> understand and fix their cars so that the customers don't have
> to.
I knew this argument comes...
> Nevertheless, I will use your analogy:
>
> You: My car shakes when I turn left. What do you think is
> wrong with it?
>
> Mechanic: Hard to say. Bring it in to the shop and I'll
> take a look.
No. It's more that I did say: The board computer message is
weird, it points to one of my tires but does not tell me the
correct error. The tire seems to be wrecked. There is a scratch -
but what could cause it? Someone with expierence (a mechanic)
know this kind of error? I kindly ask.
But mechanics do not listen and telling me I need to do an oil
change and why it's important.
--
If someone is interested:
I think it's a bug that the compiler cannot handle this recursion
correctly. By calling isCallable!S and parsing the structs "alias
this" not the complete get() content need to be parsed as only
the return type is relevant here - which is already known: T
I have to arrange that the problematic code is not parsed when
calling isCallable, so the only solution was a proxy method that
switch to get() in runtime to satisfy the compiler, not very
pretty, but works:
struct foo(T) {
alias proxy this;
T delegate() p;
// called from this(), this(this)
void initProxy() {
p = delegate() { return get; };
}
T get() {
// problematic code
}
T proxy() {
return p();
}
}
More information about the Digitalmars-d-learn
mailing list