digitalmars.D.bugs - [Issue 2913] New: aliasing a ref type is not possible
- d-bugmail puremagic.com (21/21) Apr 29 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2913
- d-bugmail puremagic.com (10/10) Apr 30 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2913
- d-bugmail puremagic.com (7/16) Apr 30 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2913
- d-bugmail puremagic.com (4/4) May 04 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2913
- d-bugmail puremagic.com (20/32) Dec 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=2913
http://d.puremagic.com/issues/show_bug.cgi?id=2913 Summary: aliasing a ref type is not possible Product: D Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: andrei metalanguage.com alias ref int rint; rint foo() { static int x; return x; } void main() { auto p = &(foo()); } This doesn't work. It led me to write the ugliest code I have ever written. Search std.range for "mixin" if you want to see ugly stuff. --
Apr 29 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2913 ------- I'm not sure allowing that alias is a good idea, as ref int and int still name the same type. If that alias worked, wouldn't you expect alias ref int rint; int i = 3; rint ri = i; ri = 4; assert(i == 4); --
Apr 30 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2913I'm not sure allowing that alias is a good idea, as ref int and int still name the same type. If that alias worked, wouldn't you expect alias ref int rint; int i = 3; rint ri = i; ri = 4; assert(i == 4);The ref would be only effective in a function signature. This can be done (I discussed it with Walter). The problem is, Walter has a lot on his plate already. Yet that doesn't make my code look any better :o). --
Apr 30 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2913 dup of bug 2753? --
May 04 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2913 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 10:45:12 PST ---So would that code error at compile-time or just silently compile and fail at runtime as if the ref didn't exist? It's tricky business.. But there's definitely a problem of not being able to pass around 'ref' in metaprogramming. The classic example being std.signal, where you can't define a signal with ref parameters: struct S { // would allow connecting to 'void f(ref int) { }' mixin Signal!(ref int); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------I'm not sure allowing that alias is a good idea, as ref int and int still name the same type. If that alias worked, wouldn't you expect alias ref int rint; int i = 3; rint ri = i; ri = 4; assert(i == 4);The ref would be only effective in a function signature.
Dec 23 2012