[Issue 17734] New: __traits(isRef) cannot currently be used to distinguish l-value from r-value passing of `this`
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Aug 8 11:33:25 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17734
Issue ID: 17734
Summary: __traits(isRef) cannot currently be used to
distinguish l-value from r-value passing of `this`
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: per.nordlow at gmail.com
__traits(isRef) cannot currently be used to distinguish l-value from r-value
passing of `this`:
# l-value passing:
S s = 42;
s.f();
# r-value passing:
S(42).f();
given that
struct SS
{
int x;
void f(int x);
}
This severly limits the possibilities of implenting C++-style expression
templates to realize lazy evaluation in operator overloading in arithmetic
types.
If this limitation were to be fixed, libraries such as gmp-d (which wrap the
C-implementation GNU MP) could implement lowering of expressions such as (in
the gmp case):
Z result = base^^exp % modulo
to the builtin
__gmpz_powm(result._ptr, base._ptr, expr._ptr, modulo._ptr)
See also: https://github.com/nordlow/gmp-d/#limitations
--
More information about the Digitalmars-d-bugs
mailing list