www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11148] New: Can't implicitly convert const(BigInt) or immutable(BigInt) to BigInt

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11148

           Summary: Can't implicitly convert const(BigInt) or
                    immutable(BigInt) to BigInt
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: joseph.wakeling webdrake.net



2013-09-30 10:45:06 PDT ---
Created an attachment (id=1253)
Can't pass const(BigInt) to a function taking a BigInt argument.

const(BigInt) or immutable(BigInt) objects can't be assigned/implicitly
converted to mutable BigInt values.  The attached code gives examples where a
const or immutable BigInt is passed to a function taking a (mutable) BigInt
argument.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 30 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11148




2013-09-30 10:45:39 PDT ---
Created an attachment (id=1254)
Can't pass immutable(BigInt) to function taking a BigInt argument.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11148




2013-10-08 09:04:03 PDT ---
Created an attachment (id=1260)
Third example, which tests implicit, explicit and cast-based conversion

In fact, there is no reliable way to convert from a qualified BigInt type to an
unqualified one.  The 3rd code example attached shows attempted conversion
through both implicit conversion (simple assignment) and explicit (trying both
std.conv.to and cast).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11148


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx



Is this really a bug? BigInt is implemented as a reference type, so allowing a
cast from const(BigInt) to BigInt would be a bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11148




2013-10-10 11:27:44 PDT ---
I think it's an issue that you can't pass an immutable(BigInt) to a function
that accepts a BigInt as input.  This makes it difficult to e.g. write generic
functions that work with any integer type.

I'm not sure what the appropriate way to deal with that is, though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11148




You can't pass an immutable(BigInt) to a function that takes unqual BigInt,
because that breaks the type system (and risks breaking immutability). The
function needs to take const(BigInt) if it doesn't need to propagate qualifiers
to its return type, or inout(BigInt) if it does.

If the function needs to modify the BigInt, then it should rightly reject any
attempt to pass in an immutable BigInt.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11148




2013-10-10 11:55:30 PDT ---

 If the function needs to modify the BigInt, then it should rightly reject any
 attempt to pass in an immutable BigInt.
Well, suppose you have some function of the form, T foo(T)(T n) { Unqual!T a = n; // ... do mutable stuff with a return a; } That still won't work if T is an immutable(BigInt), because the first line will fail: you can't copy from the immutable to mutable. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11148


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr puremagic.com



---
BigInt must behave essentially exactly like every other integral type (except
for having a larger range of possible values), which includes being a value
type.  Any internal COW implementation must be invisible to users.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 10 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11148


Simen Kjaeraas <simen.kjaras gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |simen.kjaras gmail.com



PDT ---
https://github.com/D-Programming-Language/phobos/pull/1679

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 01 2013