Thread overview |
---|
September 08, 2008 [Issue 2347] New: opIs is missing | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2347 Summary: opIs is missing Product: D Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: andrei@metalanguage.com The "is" operator is defined for built-in references and for slices. However, user-defined smart references and slices want to define it as well to integrate properly with built-in slices. The definition of opIs should follow that of opIn. -- |
September 09, 2008 [Issue 2347] opIs is missing | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2347 smjg@iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg@iname.com ------- Comment #1 from smjg@iname.com 2008-09-09 16:56 ------- I think that having opIs is philosophically wrong. The whole point of is is to override any type-defined equality operator by forcing a byte-for-byte comparison. There are probably plenty of template libraries and the like that rely on this. What are these "user-defined smart references", anyway? -- |
September 10, 2008 [Issue 2347] opIs is missing | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2347 ------- Comment #2 from 2korden@gmail.com 2008-09-10 04:25 ------- An example of "user-defined smart references" would be a ScopePtr!(T) that destroys an object when it goes out of the scope. Some reference-counted smart pointer also behaves just like an ordinary point and one would like to be able to compare SmartPtr against null using "is null" syntax: auto ptr = SmartPtr!(MyClass)(new MyClass()); assert(ptr !is null); -- |
September 10, 2008 [Issue 2347] opIs is missing | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2347 ------- Comment #3 from smjg@iname.com 2008-09-10 05:23 ------- (In reply to comment #2) > auto ptr = SmartPtr!(MyClass)(new MyClass()); > assert(ptr !is null); Hang on ... is this a smart _pointer_ or a smart _reference_? If a pointer, it makes no sense to use is to compare them as pointing to the same object. And even if it's a reference, what practical use is there in being able to use is for this? ISTM it would break more generic programming cases than it would open up. -- |
Copyright © 1999-2021 by the D Language Foundation