isRef, isLazy, isOut
Max Samukha
spambox at d-coding.com
Sun Dec 20 13:29:45 PST 2009
On 19.12.2009 23:00, Walter Bright wrote:
> Andrei Alexandrescu wrote:
>> I asked in vain for is(var == ref), is(var == out) etc.
>
> That's because 'is' works with types, not symbols. It didn't fit.
Will there be a way to get storage classes from function symbols or types?
Currently, we have to use a Signature template that, along with
parameter and return types, extracts storage classes by parsing the
value of parameter type tuple's stringof. Ugly and unreliable. We need a
way to do it without resorting to hacks. Something in this vein:
enum StorageClasses
{
...
}
class A
{
ref int foo(const ref int a, lazy int b) const;
void bar(out a);
}
assert(__traits(storageClasses, A.foo) == StorageClasses.Const |
StorageClasses.Ref);
assert(__traits(parameterStorageClasses, A.foo) == [StorageClasses.Const
| StorageClasses.Ref, StorageClasses.Lazy]);
See also http://d.puremagic.com/issues/show_bug.cgi?id=1818
More information about the Digitalmars-d
mailing list