digitalmars.D.bugs - [Issue 4977] New: cannot use nothrow or pure with Rebindable
- d-bugmail puremagic.com (35/35) Oct 02 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4977
- d-bugmail puremagic.com (9/9) Oct 02 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4977
- d-bugmail puremagic.com (63/63) Oct 02 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4977
- d-bugmail puremagic.com (7/7) Oct 02 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4977
- d-bugmail puremagic.com (10/10) Aug 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4977
- d-bugmail puremagic.com (11/11) Sep 06 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4977
http://d.puremagic.com/issues/show_bug.cgi?id=4977 Summary: cannot use nothrow or pure with Rebindable Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: jmdavisProg gmx.com PDT --- Rebindable does nothing about nothrow or pure. None of its functions are marked on nothrow or pure, making it rather difficult to use Rebindable with a type which has carefully been made to correctly use nothrow and/or pure. The first thing would be to make opDot() nothrow and pure. I'm pretty sure that you can get away with that (though pure may not be possible until the next version of the compiler is released with the changes to pure that Don suggested). opAssign() would probably be just as easy, though I'm not sure. Since we're dealing with copying classes, interfaces, or arrays, I think that you can just make opAssign nothrow with no problem (since you have no postblit constructor to worry about possibly throwing). On purity, I'm not so sure. It might work now, or it might require the changes Don suggested, but I think that it will work at that point. Since the constructor uses opAssign(), it will probably be just as easy/difficult to change as opAssign will be. In any case, as it stands, its rather difficult to use either nothrow or pure with Rebindable, which either severely limits where you can use Rebindable, or it severely limits the type that you put in Rebindable. rebindable() will likely have to be changed appropriately as well. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 02 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4977 PDT --- It looks like opDot() doesn't work with const or immutable Rebindable!()'s. So, it probably needs a second version which is const (and possible a third for immutable) in order to work with them. Otherwise, const member functions don't work very well with member variables which are Rebindable!(). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 02 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4977 PDT --- Here's a first attempt at a solution: Rebindable(T) if (is(T == class) || is(T == interface) || isArray!(T)) { static if (!is(T X == const(U), U) && !is(T X == immutable(U), U)) { alias T Rebindable; } else static if (isArray!(T)) { alias const(ElementType!(T))[] Rebindable; } else { struct Rebindable { private union { T original; U stripped; } void opAssign(T another) nothrow { stripped = cast(U) another; } void opAssign(Rebindable another) nothrow { stripped = another.stripped; } static if (is(T == const U)) { // safely assign immutable to const void opAssign(Rebindable!(immutable U) another) nothrow { stripped = another.stripped; } } this(T initializer) nothrow { opAssign(initializer); } property T get() const pure nothrow { return original; } T opDot() pure nothrow { return original; } T opDot() const pure nothrow { return original; } } } } With the current purity rules, I can't make opAssign() pure. It complains about assigning to const. I don't know whether or nat that will be fixed with the relaxed purity rules suggested by Don. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 02 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4977 PDT --- needing a const version with both versions being nothrow. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 02 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4977 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch https://github.com/D-Programming-Language/phobos/pull/213 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 23 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4977 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED https://github.com/D-Programming-Language/phobos/commit/936f2a4c38dcca8cfe0a7e4247bddcff2f19f8ba -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 06 2011