Bug 1288 – Variables with type tuple as type should be able to act as lvalues

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Linux
Creation time
2007-06-23T15:15:00Z
Last change time
2014-02-16T15:23:07Z
Assigned to
bugzilla
Creator
onlystupidspamhere

Comments

Comment #0 by onlystupidspamhere — 2007-06-23T15:15:33Z
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)
Comment #1 by davidl — 2007-06-26T23:23:17Z
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
Comment #2 by onlystupidspamhere — 2007-06-27T03:08:19Z
(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.