Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
August 01, 2009 [Issue 3221] New: Array extension methods require parentheses | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3221 Summary: Array extension methods require parentheses Product: D Version: 2.032 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: johnch_atms@hotmail.com Free functions can be used as methods of an array if the first argument in the function definition is an array. For example: int indexOf(T)(T[] array, T value) {...} int[] ints = getInts(); int i = ints.indexOf(2); However, when the array argument is called without parameters, the expression fails to compile, as this example shows. string[] split(string s, string sep) { ... } class Person { string name_; string name() { return name_; } } auto person = getPerson(); string[] firstAndLast = person.name.split(" "); The above line will only compile if it is changed to: string[] firstAndList = person.name().split(" "); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 01, 2009 [Issue 3221] Array extension methods require parentheses | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3221 --- Comment #1 from johnch_atms@hotmail.com 2009-08-01 03:52:51 PDT --- (In reply to comment #0) > Free functions can be used as methods of an array if the first argument in the > function definition is an array. For example: > int indexOf(T)(T[] array, T value) {...} > int[] ints = getInts(); > int i = ints.indexOf(2); > However, when the array argument is called without parameters, the expression > fails to compile, as this example shows. > string[] split(string s, string sep) { ... } > class Person { > string name_; > string name() { return name_; } > } > auto person = getPerson(); > string[] firstAndLast = person.name.split(" "); > The above line will only compile if it is changed to: > string[] firstAndList = person.name().split(" "); Oops, I meant to say: However, when the array argument is called without parentheses, the expression fails to compile... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 05, 2010 [Issue 3221] Array extension methods require parentheses | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3221 Witold Baryluk <baryluk@smp.if.uj.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |baryluk@smp.if.uj.edu.pl --- Comment #2 from Witold Baryluk <baryluk@smp.if.uj.edu.pl> 2010-02-05 06:22:09 PST --- One should possibly add @property for such function, so it will be possible tu use such function not only as method but also as getter. Unfortunetly it isn't yet implemented. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 05, 2010 [Issue 3221] Array extension methods require parentheses | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3221 --- Comment #3 from Witold Baryluk <baryluk@smp.if.uj.edu.pl> 2010-02-05 06:24:01 PST --- Similary to the bug3771 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 01, 2012 [Issue 3221] (D1 only) Can't use property syntax with ufcs | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3221 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid CC| |yebblies@gmail.com Version|2.032 |D1 Summary|Array extension methods |(D1 only) Can't use |require parentheses |property syntax with ufcs --- Comment #4 from yebblies <yebblies@gmail.com> 2012-02-02 02:33:23 EST --- Works in D2 (2.058) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 02, 2012 [Issue 3221] (D1 only) Can't use property syntax with ufcs | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3221 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #5 from yebblies <yebblies@gmail.com> 2012-02-02 20:52:09 EST --- *** This issue has been marked as a duplicate of issue 2883 *** -- 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