Worst ideas/features in programming languages?
Paul Backus
snarwin at gmail.com
Thu Jan 6 06:04:24 UTC 2022
On Thursday, 6 January 2022 at 02:56:52 UTC, Tejas wrote:
> On Wednesday, 5 January 2022 at 22:42:14 UTC, Paul Backus wrote:
>> On Wednesday, 5 January 2022 at 07:28:41 UTC, Timon Gehr wrote:
>>>
>>> How about something like opArgs, dealing specifically with
>>> this case? (i.e., a function call `foo(x)` with a single
>>> argument is immediately rewritten to `foo(x.opArgs)` if `x`
>>> has a member `opArgs`, and this rewrite is applied exactly
>>> once.)
>>
>> [...]
>
> Yeah, and what does "exactly once" mean here?
I assume it means "once per argument"; i.e., the rewrite is not
applied recursively to its own result. For example:
```d
struct A { B opArgs; }
struct B { C opArgs; }
struct C {}
string fun(A) { return "A"; }
string fun(B) { return "B"; }
string fun(C) { return "C"; }
void main() {
assert(fun(A()) == "B");
}
```
`A()` is rewritten to `A().opArgs`, but `A().opArgs` is **not**
rewritten to `A().opArgs.opArgs`.
More information about the Digitalmars-d
mailing list