[Issue 20178] New: Add TypeInfo_Class/TypeInfo_Interface.isDerivedFrom (equivalent to of C#/Java isAssignableFrom with the argument swapped with the receiver)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 28 23:49:45 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20178
Issue ID: 20178
Summary: Add TypeInfo_Class/TypeInfo_Interface.isDerivedFrom
(equivalent to of C#/Java isAssignableFrom with the
argument swapped with the receiver)
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: n8sh.secondary at hotmail.com
C# System.Type and Java java.lang.Class have `isAssignableFrom` to conveniently
determine at runtime whether a class inherits from or implements another class
or interface. Adding something similar to TypeInfo_Class and TypeInfo_Interface
would be useful.
The name "isAssignableFrom" would be familiar to people coming from C# or Java
but is potentially misleading since since -- due to "alias this" and the
ability to overload opAssign -- whether a value of type Y can be assigned to a
variable of type X is not the same as asking if Y inherits from or implements
X. The language "derives from" is used in the D specification so I'm suggesting
"isDerivedFrom" swapping the receiver and argument relative to
"isAssignableFrom."
--
More information about the Digitalmars-d-bugs
mailing list