digitalmars.D.bugs - [Issue 5604] New: Clarify whether this is a bug or a feature
- d-bugmail puremagic.com (30/30) Feb 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5604
- d-bugmail puremagic.com (12/12) Feb 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5604
- d-bugmail puremagic.com (24/24) Feb 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5604
http://d.puremagic.com/issues/show_bug.cgi?id=5604 Summary: Clarify whether this is a bug or a feature Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: spec Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: dsimcha yahoo.com --- Comment #0 from David Simcha <dsimcha yahoo.com> 2011-02-17 08:30:33 PST --- The following code compiles in 64-bit mode and arguably shouldn't (but arguably should). void main() { int[] foo; foreach(uint i, elem; foo) {} } The index variable into foo is technically a size_t, not a uint. On the other hand this is arguably a feature. The idiomatic way to write a foreach loop is with implicit variable typing. The insertion of an explicit type is, IMHO, equivalent to using an explicit cast, and therefore it arguably should compile. Personally, I prefer this to be considered a feature rather than a bug, but either way I think it's important that the spec be clarified, as I've used this idiom in several places when porting code to 64-bit. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 17 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5604 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |INVALID --- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2011-02-17 10:52:26 PST --- It's a feature, as you can still use uints to index an array in 64 bit code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 17 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5604 Steven Schveighoffer <schveiguy yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schveiguy yahoo.com --- Comment #2 from Steven Schveighoffer <schveiguy yahoo.com> 2011-02-17 11:28:01 PST --- I really expected this to be a bug. Because I would expect this to fail: struct S { int opApply(int delegate(ref size_t idx, ref int val) dg) { return 0; } } void main() { S s; foreach(uint idx, int val; s) {} } i.e. you cannot possibly duplicate this 'feature' for a custom structure. But then of course, you cannot duplicate the 'no ref' aspect of the index either. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 17 2011