www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1288] New: Variables with type tuple as type should be able to act as lvalues

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

           Summary: Variables with type tuple as type should be able to act
                    as lvalues
           Product: D
           Version: 1.016
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: onlystupidspamhere yahoo.se


This works

  template Tuple(T...) { alias T Tuple; }

  void main() {
    Tuple!(int,int) foo;

but

    foo = Tuple!(1,1);
  }

causes

Error: foo is not an lvalue
Error: forward reference to type (int, int)
Error: cannot implicitly convert expression (tuple(1,1)) of type (int, int) to
(int, int)
Error: cannot cast int to (int, int)


-- 
Jun 23 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1288


davidl 126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from davidl 126.com  2007-06-26 23:23 -------

IMO, your code should be as following:

import std.bind;

void main() {
  Tuple!(int,int) foo;

  foo = Tuple!(int,int)(1,1);
}

And the compiler emits the correct message IMO
If this is something about first class tuple, it's already on bug 1293
But I don't think D is gonna integrate such obscure builtin tuple. 
And even first class tuple gets integrated , I still consider your code
shouldn't
work


-- 
Jun 26 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1288


onlystupidspamhere yahoo.se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED




------- Comment #2 from onlystupidspamhere yahoo.se  2007-06-27 03:08 -------
(In reply to comment #1)
 IMO, your code should be as following:
 
 import std.bind;
 
 void main() {
   Tuple!(int,int) foo;
 
   foo = Tuple!(int,int)(1,1);
 }
 
 And the compiler emits the correct message IMO

std.bind uses parametrized structs as tuples, that's why the assignment works. It's simply a workaround. IIRC you can see from the executable that those assignments generate unnecessary runtime code.
 If this is something about first class tuple, it's already on bug 1293

For most parts, yes. I left this open because it's a easier to implement and I could have use for it without having e.g. tuple literals. But I'll leave this closed now.
 But I don't think D is gonna integrate such obscure builtin tuple. 
 And even first class tuple gets integrated , I still consider your code
 shouldn't work

I would leave that for Walter to decide. --
Jun 27 2007