Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
November 03, 2009 [Issue 3470] New: [tdpl]: .length should not pop up inside indexing expressions. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3470 Summary: [tdpl]: .length should not pop up inside indexing expressions. Product: D Version: 2.035 Platform: Other OS/Version: All Status: NEW Keywords: patch Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: clugdbug@yahoo.com.au --- Comment #0 from Don <clugdbug@yahoo.com.au> 2009-11-03 00:03:10 PST --- Found this in the "thermoplyae" excerpt. ---- PATCH: dsymbol.c, ArrayScopeSymbol::search(), line 1062 //printf("ArrayScopeSymbol::search('%s', flags = %d)\n", ident->toChars(), flags); - if (ident == Id::length || ident == Id::dollar) + if (ident == Id::dollar) { VarDeclaration **pvar; ---- I have already made the changes to druntime (svn 192) and Phobos (svn 1319), so that they'll pass all unit tests once this change has been made. COMMENT: From the changelog for DMD 0.115 (Mar 7, 2005!!!): $ can now be used instead of length inside an array's []. It represents the length of the array. This is a trial feature, if it works out then these will happen in sequential releases: 1. length will become deprecated inside []. 2. length will be removed as the implicitly declared length, and it will be just another identifier. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 03, 2009 [Issue 3470] [tdpl]: .length should not pop up inside indexing expressions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3470 --- Comment #1 from Don <clugdbug@yahoo.com.au> 2009-11-03 03:41:38 PST --- Note for Walter: This is the list of test suite files which are using [length] and need to change to [$]: test16 test23 test34 test42 template4 template6 hospital stress lazy variadic testfile -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 03, 2009 [Issue 3470] [tdpl]: .length should not pop up inside indexing expressions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3470 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrei@metalanguage.com --- Comment #2 from Andrei Alexandrescu <andrei@metalanguage.com> 2009-11-03 05:15:37 PST --- Great work, Don! Since you're there and the code is fresh in your mind, I suggest you operate these two additional changes that were discussed in the newsgroup several times: a) In single-argument index and slice expressions, rewrite $ to __a.length, where __a is the already-evaluated array being indexed/sliced. b) In multi-argument index and slice expressions, rewrite $ to __a.lengths!(n), where n is the compile-time argument position where $ appears. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 04, 2009 [Issue 3470] [tdpl]: .length should not pop up inside indexing expressions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3470 --- Comment #3 from Don <clugdbug@yahoo.com.au> 2009-11-04 12:16:12 PST --- (In reply to comment #2) > Great work, Don! Since you're there and the code is fresh in your mind, I suggest you operate these two additional changes that were discussed in the newsgroup several times: > > a) In single-argument index and slice expressions, rewrite $ to __a.length, where __a is the already-evaluated array being indexed/sliced. > > b) In multi-argument index and slice expressions, rewrite $ to __a.lengths!(n), > where n is the compile-time argument position where $ appears. Actually, the 'opDollar' problem is not very similar to this one, so I'll create a new ticket for it. I've had a go at it. The difficult bit is that currently '$' turns into a symbol, but it needs to become an expression, and it needs the 'this' pointer, which isn't in scope. I can get around this by creating local variables to hold the various values of $ for each dimension, but I'm not sure if that's the right approach. Still not working, but close. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 06, 2009 [Issue 3470] [tdpl]: .length should not pop up inside indexing expressions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3470 --- Comment #4 from Sobirari Muhomori <dfj1esp02@sneakemail.com> 2009-11-06 02:40:23 PST --- Why? Is it because compiler doesn't detect ambiguity/shadowing? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 06, 2009 [Issue 3470] [tdpl]: .length should not pop up inside indexing expressions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3470 --- Comment #5 from Andrei Alexandrescu <andrei@metalanguage.com> 2009-11-06 07:00:23 PST --- (In reply to comment #4) > Why? Is it because compiler doesn't detect ambiguity/shadowing? There were discussions in the newsgroup in the past. In brief it is bad practice to have the language introduce identifiers automatically in select places. Essentially that makes the identifiers de facto keywords because you shouldn't use them as regular identifiers - they could always be shadowed. Searching the title of the newgroup for "length" shows many related conversations. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 12, 2010 [Issue 3470] [tdpl]: .length should not pop up inside indexing expressions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3470 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #6 from Don <clugdbug@yahoo.com.au> 2010-03-12 14:10:09 PST --- Fixed DMD2.041. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation