View mode: basic / threaded / horizontal-split · Log in · Help
January 12, 2012
[Issue 7273] New: Tuples conversion assign
http://d.puremagic.com/issues/show_bug.cgi?id=7273

          Summary: Tuples conversion assign
          Product: D
          Version: D2
         Platform: x86
       OS/Version: Windows
           Status: NEW
         Keywords: rejects-valid
         Severity: enhancement
         Priority: P2
        Component: Phobos
       AssignedTo: nobody@puremagic.com
       ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2012-01-11 19:55:45 PST ---
Currently D tuples are library defined, and this probably gives some small
restrictions.

But I think well implemented built-in tuples should allow code like this,
because here we are assigning an immutable value and copying it to a mutable
one:


import std.typecons: Tuple, tuple;
Tuple!(int) foo() {
   immutable int x = 1;
   return tuple(x);
}
void main() {}



DMD 2.058head:
test.d(4): Error: cannot implicitly convert expression (tuple(1)) of type
Tuple!(immutable(int)) to Tuple!(int)


Because this code is allowed, and tuples too are values:

int foo() {
   immutable int x = 1;
   return x;
}
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 12, 2012
[Issue 7273] Tuples conversion assign
http://d.puremagic.com/issues/show_bug.cgi?id=7273



--- Comment #1 from bearophile_hugs@eml.cc 2012-01-12 10:54:55 PST ---
Note this currently works:


import std.typecons: Tuple, tuple;
void main() {
   immutable int x = 1;
   Tuple!(int) y = tuple(1);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 22, 2013
[Issue 7273] Tuples conversion assign
http://d.puremagic.com/issues/show_bug.cgi?id=7273


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |andrej.mitrovich@gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-21 17:58:38 PST ---
(In reply to comment #1)
> Note this currently works:
> 
> 
> import std.typecons: Tuple, tuple;
> void main() {
>     immutable int x = 1;
>     Tuple!(int) y = tuple(1);
> }

I think you meant to write:

Tuple!(int) y = tuple(x);

Anyway this seems like more of a compiler issue than a library issue, because I
don't think we can fix this in the library.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home