Thread overview | |||||
---|---|---|---|---|---|
|
June 12, 2013 UFCS and "with" statement | ||||
---|---|---|---|---|
| ||||
struct S { } void f(S) { } void main() { S s; with (s) { f(); // compiler error } } Rather disappointing that this fails. Anyone know if this is an expected limitation of UFCS or a bug? --rt |
June 12, 2013 Re: UFCS and "with" statement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rob T | Rob T:
> Rather disappointing that this fails. Anyone know if this is an expected limitation of UFCS or a bug?
Probably no one thought on this case. Why do you think it's useful?
Bye,
bearophile
|
June 13, 2013 Re: UFCS and "with" statement | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Wednesday, 12 June 2013 at 11:05:22 UTC, bearophile wrote:
> Rob T:
>
>> Rather disappointing that this fails. Anyone know if this is an expected limitation of UFCS or a bug?
>
> Probably no one thought on this case. Why do you think it's useful?
>
> Bye,
> bearophile
If we're to use UFCS as a means to externally extend classes and structs, then UFCS should work as an extension under a with statement, otherwise UFCS is not living up to its full potential.
struct S
{
void a(){ ... }
void b(){ ... }
void d(){ ... }
}
void c(S s){ ... }
void main()
{
with (s)
{
a;
b;
c; // should be able to infer s.c just as it can infer s.b, etc
d;
}
}
--rt
|
Copyright © 1999-2021 by the D Language Foundation