digitalmars.D - foreach_reverse is better than ever
- Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> Feb 13 2010
- Jonathan M Davis <jmdavisProg gmail.com> Feb 14 2010
- Jacob Carlborg <doob me.com> Feb 14 2010
- Michel Fortin <michel.fortin michelf.com> Feb 14 2010
- bearophile <bearophileHUGS lycos.com> Feb 14 2010
- Michel Fortin <michel.fortin michelf.com> Feb 14 2010
- Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> Feb 14 2010
- Mike James <foo bar.com> Feb 14 2010
- bearophile <bearophileHUGS lycos.com> Feb 14 2010
- Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> Feb 14 2010
- bearophile <bearophileHUGS lycos.com> Feb 14 2010
- Justin Johansson <no spam.com> Feb 14 2010
- "Nick Sabalausky" <a a.a> Feb 14 2010
- KennyTM~ <kennytm gmail.com> Feb 16 2010
- Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> Feb 14 2010
- Mike James <foo bar.com> Feb 14 2010
- "Nick Sabalausky" <a a.a> Feb 14 2010
- Mike James <foo bar.com> Feb 14 2010
- Justin Johansson <no spam.com> Feb 14 2010
- Ary Borenszweig <ary esperanto.org.ar> Feb 14 2010
- Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> Feb 14 2010
- Ary Borenszweig <ary esperanto.org.ar> Feb 15 2010
- Michel Fortin <michel.fortin michelf.com> Feb 15 2010
- Jacob Carlborg <doob me.com> Feb 15 2010
- Jonathan M Davis <jmdavisProg gmail.com> Feb 15 2010
- Michel Fortin <michel.fortin michelf.com> Feb 15 2010
- dsimcha <dsimcha yahoo.com> Feb 15 2010
- bearophile <bearophileHUGS lycos.com> Feb 15 2010
- Justin Johansson <no spam.com> Feb 15 2010
- Yigal Chripun <yigal100 gmail.com> Feb 16 2010
- Yigal Chripun <yigal100 gmail.com> Feb 16 2010
- torhu <no spam.invalid> Feb 15 2010
- "Adam D. Ruppe" <destructionator gmail.com> Feb 14 2010
- Igor Lesik <curoles yahoo.com> Feb 14 2010
- "Nick Sabalausky" <a a.a> Feb 14 2010
- retard <re tard.com.invalid> Feb 14 2010
- retard <re tard.com.invalid> Feb 14 2010
- Daniel Murphy <yebbliesnospam gmail.com> Feb 14 2010
- bearophile <bearophileHUGS lycos.com> Feb 14 2010
- bearophile <bearophileHUGS lycos.com> Feb 14 2010
- Michel Fortin <michel.fortin michelf.com> Feb 14 2010
- dsimcha <dsimcha yahoo.com> Feb 14 2010
- dsimcha <dsimcha yahoo.com> Feb 14 2010
- "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> Feb 14 2010
- grauzone <none example.net> Feb 14 2010
- dsimcha <dsimcha yahoo.com> Feb 14 2010
- Mike James <foo bar.com> Feb 14 2010
- Bane <branimir.milosavljevic gmail.com> Feb 14 2010
- Leandro Lucarella <llucax gmail.com> Feb 14 2010
- Leandro Lucarella <llucax gmail.com> Feb 15 2010
- Leandro Lucarella <llucax gmail.com> Feb 15 2010
- Leandro Lucarella <llucax gmail.com> Feb 15 2010
- "Steven Schveighoffer" <schveiguy yahoo.com> Feb 15 2010
Gone, that is. Walter agreed to remove it.
To achieve the functionality of
foreach_reverse (r) { ... }
use
foreach (retro(r)) { ... }
using retro in std.range.
Andrei
Feb 13 2010
Andrei Alexandrescu wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range. Andrei
I assume that this was to get rid of a keyword and reduce duplicate functionality. Though I must say that I find retro to be a bit funny. I would have expected it to be reverse. It would be clearer, I think, but it's not like it's hard to find out what retro does and remember it. - Jonathan M Davis
Feb 14 2010
On 2/14/10 09:14, Jonathan M Davis wrote:Andrei Alexandrescu wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range. Andrei
I assume that this was to get rid of a keyword and reduce duplicate functionality. Though I must say that I find retro to be a bit funny. I would have expected it to be reverse. It would be clearer, I think, but it's not like it's hard to find out what retro does and remember it. - Jonathan M Davis
It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word. /Jacob Carlborg
Feb 14 2010
On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
Agree. My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Feb 14 2010
Michel Fortin:It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
In Python it's "reversed":a = [5,7,1,3] reversed(a)
list(reversed(a))
Python use verbs in past tense (like "sorted", "reversed", etc) to denote something that doesn't change the given input (while "sort" sorts in-place). Bye, bearophile
Feb 14 2010
On 2010-02-14 09:34:16 -0500, bearophile <bearophileHUGS lycos.com> said:Python use verbs in past tense (like "sorted", "reversed", etc) to denote something that doesn't change the given input (while "sort" sorts in-place).
That certainly is a useful convention to make things easier to read. I'd very much like to see it used in D. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Feb 14 2010
Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
Feb 14 2010
Andrei Alexandrescu Wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
1. Contrawise 2. Rearward 3. AssBackwards 4. Reorientated 5. Turnedabout 6. Turnedaround 7. Inversified 8. Flipped 9. Refluxed 10. VolteFace or how about Reverse... -=mike=-
Feb 14 2010
Mike James:1. Contrawise 2. Rearward 3. AssBackwards 4. Reorientated 5. Turnedabout 6. Turnedaround 7. Inversified 8. Flipped 9. Refluxed 10. VolteFace or how about Reverse...
Wonderful, I elect you the official namer for Phobos :-) And I think Andrei meant a list of all the bad names in Phobos :-) What about "reversed"? :-) Bye, bearophile
Feb 14 2010
bearophile wrote:Mike James:1. Contrawise 2. Rearward 3. AssBackwards 4. Reorientated 5. Turnedabout 6. Turnedaround 7. Inversified 8. Flipped 9. Refluxed 10. VolteFace or how about Reverse...
Wonderful, I elect you the official namer for Phobos :-) And I think Andrei meant a list of all the bad names in Phobos :-) What about "reversed"? :-)
I don't mind "reversed" but it's longer than "retro" and the convention doesn't scale. For example, both active and passive forms of "split" look the same. Andrei
Feb 14 2010
Andrei Alexandrescu:I don't mind "reversed" but it's longer than "retro" and the convention doesn't scale. For example, both active and passive forms of "split" look the same.
For me "retro" is acceptable. I don't love "iota" but I can accept it too. Other names of Phobos2 can be improved. Bye, bearophile
Feb 14 2010
bearophile wrote:Andrei Alexandrescu:I don't mind "reversed" but it's longer than "retro" and the convention doesn't scale. For example, both active and passive forms of "split" look the same.
For me "retro" is acceptable. I don't love "iota" but I can accept it too. Other names of Phobos2 can be improved. Bye, bearophile
Go language has "iota" so it's gotta be goodness :-)
Feb 14 2010
"bearophile" <bearophileHUGS lycos.com> wrote in message news:hl9ipc$26r1$1 digitalmars.com...Andrei Alexandrescu:I don't mind "reversed" but it's longer than "retro" and the convention doesn't scale. For example, both active and passive forms of "split" look the same.
For me "retro" is acceptable. I don't love "iota" but I can accept it too. Other names of Phobos2 can be improved.
I can be happy with either 'retro' or 'reverse'. My feeling on 'iota' used to be "It's not great, but I'm fine with it". But now I can't remember what the hell it does; no idea. The only things that come to mind are "Dyslexic Integer to ASCII conversion", and Futurama's "Tiny Iota? I could never be as good as him. He was a great Blurnsball player."
Feb 14 2010
Nick Sabalausky wrote:"bearophile" <bearophileHUGS lycos.com> wrote in message news:hl9ipc$26r1$1 digitalmars.com...Andrei Alexandrescu:I don't mind "reversed" but it's longer than "retro" and the convention doesn't scale. For example, both active and passive forms of "split" look the same.
Other names of Phobos2 can be improved.
I can be happy with either 'retro' or 'reverse'. My feeling on 'iota' used to be "It's not great, but I'm fine with it". But now I can't remember what the hell it does; no idea. The only things that come to mind are "Dyslexic Integer to ASCII conversion", and Futurama's "Tiny Iota? I could never be as good as him. He was a great Blurnsball player."
retro does have something going for it that iota doesn't. Everybody I talked to who saw "retro" in my article on ranges knew immediately what it does, and furthermore remembered the name later. Andrei
Feb 14 2010
On Feb 15, 10 02:08, Andrei Alexandrescu wrote:bearophile wrote:Mike James:1. Contrawise 2. Rearward 3. AssBackwards 4. Reorientated 5. Turnedabout 6. Turnedaround 7. Inversified 8. Flipped 9. Refluxed 10. VolteFace or how about Reverse...
Wonderful, I elect you the official namer for Phobos :-) And I think Andrei meant a list of all the bad names in Phobos :-) What about "reversed"? :-)
I don't mind "reversed" but it's longer than "retro" and the convention doesn't scale. For example, both active and passive forms of "split" look the same. Andrei
Why do you want to perform an in-place split?
Feb 16 2010
Mike James wrote:Andrei Alexandrescu Wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
(the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
1. Contrawise 2. Rearward 3. AssBackwards 4. Reorientated 5. Turnedabout 6. Turnedaround 7. Inversified 8. Flipped 9. Refluxed 10. VolteFace or how about Reverse... -=mike=-
I meant a list with other cases (aside from this particular one) in which choices of names were unfortunate. I thought the following is clear but let me state it: in this particular case, using "reverse" is not desirable because the name already exists as an array property. If we drop the existing feature and choose "reverse" for the new feature, code will silently change semantics. Andrei
Feb 14 2010
Andrei Alexandrescu Wrote:Mike James wrote:Andrei Alexandrescu Wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
(the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
1. Contrawise 2. Rearward 3. AssBackwards 4. Reorientated 5. Turnedabout 6. Turnedaround 7. Inversified 8. Flipped 9. Refluxed 10. VolteFace or how about Reverse... -=mike=-
I meant a list with other cases (aside from this particular one) in which choices of names were unfortunate. I thought the following is clear but let me state it: in this particular case, using "reverse" is not desirable because the name already exists as an array property. If we drop the existing feature and choose "reverse" for the new feature, code will silently change semantics. Andrei
I can understand that, but the problem is - the dictionary definition of 'retro' is 'associated with or revived from the past'. It doesn't correctly describe the action. It could generate many hours of semiotic arguements... ;=) -=mike=-
Feb 14 2010
"Mike James" <foo bar.com> wrote in message news:hl9i1q$24m0$1 digitalmars.com...I can understand that, but the problem is - the dictionary definition of 'retro' is 'associated with or revived from the past'. It doesn't correctly describe the action. It could generate many hours of semiotic arguements... ;=)
I think there's probably a lot of cases where dictionary definitions don't quite match a word's usage in the programming world. "Kill", "thread", "string", "rake" (the ruby build tool) all come to mind. Of course, "retro" might be argued to be more of a stretch than some of those, but you can also think of "retro" just referring to the prefix "retro" (which does basically just mean "backwards", AIUI) rather than the actual word "retro".
Feb 14 2010
Andrei Alexandrescu Wrote:Mike James wrote:Andrei Alexandrescu Wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
(the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
1. Contrawise 2. Rearward 3. AssBackwards 4. Reorientated 5. Turnedabout 6. Turnedaround 7. Inversified 8. Flipped 9. Refluxed 10. VolteFace or how about Reverse... -=mike=-
I meant a list with other cases (aside from this particular one) in which choices of names were unfortunate. I thought the following is clear but let me state it: in this particular case, using "reverse" is not desirable because the name already exists as an array property. If we drop the existing feature and choose "reverse" for the new feature, code will silently change semantics. Andrei
Interestingly enough, although 'invert' means turning something upside down, according to the dictionary, it can also imply reversing something... would 'Invert' be applicable? -=mike=-
Feb 14 2010
Andrei Alexandrescu wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
How about esrever with credit for original idea going to highly creative Unix script language designers as in if ... fi esrever has attributes (b) and (c) (definitely memorable). (a), well no, arguably it's not short. so I guess it really is a no brainer, then. How about ver )-: nitsuJ
Feb 14 2010
Justin Johansson wrote:Andrei Alexandrescu wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
How about esrever
Nah, hcaerof
Feb 14 2010
retard wrote:Sun, 14 Feb 2010 11:18:02 -0600, Andrei Alexandrescu wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
(the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list.
It sounds like a flaw in the language design if the symbols for reversing arrays and ranges somehow conflict.
There are two operations: reverse the thing in place, and span it in retrograde order. Andrei
Feb 14 2010
Andrei Alexandrescu wrote:retard wrote:Sun, 14 Feb 2010 11:18:02 -0600, Andrei Alexandrescu wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
(the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list.
It sounds like a flaw in the language design if the symbols for reversing arrays and ranges somehow conflict.
There are two operations: reverse the thing in place, and span it in retrograde order. Andrei
asterite deep-water:~$ irb irb(main):001:0> a = [1, 2, 3] => [1, 2, 3] irb(main):002:0> a.reverse => [3, 2, 1] irb(main):003:0> a => [1, 2, 3] irb(main):004:0> a.reverse! => [3, 2, 1] irb(main):005:0> a => [3, 2, 1] irb(main):006:0> Aaaah... ruby <3
Feb 15 2010
On 2010-02-15 09:04:11 -0500, Leandro Lucarella <llucax gmail.com> said:Andrei Alexandrescu, el 14 de febrero a las 20:24 me escribiste:There are two operations: reverse the thing in place, and span it in retrograde order.
I think reverse (in-place) and reversed (returns a range that iterates in reverse order) are *very* clear in terms of that distinction.
But now how do you distinguish between a function returning the reversed form of something and a function returning true when that thing is reversed? :-) In Ruby syntax things are generally pretty easy: something.reverse! # reverse in place ('dangerous!' method) something.reverse # reverse a copy something.reversed? # return whether something is reversed or not Cocoa would use a slightly different notation: [something reverse]; // reverse in place [something reversedSomething]; // reverse a copy [something isReversed]; // return whether something is reversed or not Both conventions are very clear and scale well even for words like 'split' which are identical in their past and present tense. It's unclear to me how we want this to be done in D... something.reverse(); // reverse in place something.reversed; // reverse a copy something.reversed(); // ditto something.reverse(); // ditto something.reversed; // return whether something is reversed or not something.isReversed; // ditto If we want some consistency, someone with authority over Phobos will have to draw some guidelines about this, and sooner the better. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Feb 15 2010
On 2/14/10 18:18, Andrei Alexandrescu wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
I never understood the reason for that the names need to be short. I think the most important thing is that the names are clear. Just look at the C standard library, it's horrible, almost every name is an abbreviation of some kind.
Feb 15 2010
Jacob Carlborg wrote:I never understood the reason for that the names need to be short. I think the most important thing is that the names are clear. Just look at the C standard library, it's horrible, almost every name is an abbreviation of some kind.
Clarity is very important, but if you have long names which are used frequently, it can quickly result in long lines of code which end up on multiple lines and can be hard to read. If a word isn't used very often, then it's not that big a deal, but the more often it's used - especially when it can be used multiple times on the same line - the worse it gets. Really, the ideal situation is to find words which are short and clear, but a balance must be struck between the two regardless. Too long and it's cumbersome. Too short and it's likely to be unclear. There's no question that programmers often use words for variable names and such which are ludicrously short and unclear, but long words can be a problem too. - Jonathan M Davis
Feb 15 2010
On 2010-02-15 08:59:43 -0500, Jonathan M Davis <jmdavisProg gmail.com> said:Clarity is very important, but if you have long names which are used frequently, it can quickly result in long lines of code which end up on multiple lines and can be hard to read. If a word isn't used very often, then it's not that big a deal, but the more often it's used - especially when it can be used multiple times on the same line - the worse it gets.
Well, the problem is that whether you're using something often or not depends on the context. If in a context your function name is used once or two, but in another it's used a lot, which prevails: shortness or clarity? I'd tend to put clarity over short names in D because the language makes it very easy to create shorter aliases limited in scope when the need arise. But you shouldn't repeat the argument types nor the module's name: the language takes care of that for you.Really, the ideal situation is to find words which are short and clear, but a balance must be struck between the two regardless. Too long and it's cumbersome. Too short and it's likely to be unclear.
There's no question that programmers often use words for variable names and such which are ludicrously short and unclear, but long words can be a problem too.
I think it's a question of locality. The broader is the scope of a name the more self-explaining the name should be. As an extreme example, I don't mind much seeing a local variable named 'x' in a short function, but I wouldn't accept that as a member variable in a class, and even less for a global variable. It's easy for someone to create short names when he is all absorbed in what he's doing. But I think it generally takes some detachment to get the names right for a public API. Ideally, API names should be understandable as soon as you understand the underlying concepts. But even more important is that __functions should never be understood wrong__, the name should be clear enough to ensure that. I don't think std.range fare very well at this readability test. Take this example: int[] array = [1,2,3,4,5,6,7,8,9]; auto five = take(5, array); writeln(array); // what are you expecting here? In the case above, 'take' returns a range that lazily takes N elements when you iterate over it. If you don't use the returned range, 'take' is as good as a no-op. But this subtle interaction isn't very clear when you just read the code. Last week I defined my own function named 'take' for some kind of parser, advancing the range by the number of specified elements and returning an array of all the 'taken' elements. Then I realized it had the same name as the one above but with this subtle difference in semantics, subtle but very important for what I was doing. I renamed my function since then to make things less confusing, but I'm still a little shaken by this whole incident. I think the lazy nature of 'take' should be visible when calling the function. This could be achieved by a name change, or perhaps in another way. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Feb 15 2010
== Quote from Jacob Carlborg (doob me.com)'s articleI never understood the reason for that the names need to be short. I think the most important thing is that the names are clear. Just look at the C standard library, it's horrible, almost every name is an abbreviation of some kind.
Names should be short to save typing and clutter. Of course, clarity also matters. I tend to prefer short names for frequently used language and library constructs that everyone who has been using the language for more than two weeks should know. Longer names have their use in **your** programs and in less frequently used constructs, where the overhead of memorizing what a short, unclear name means is less than the overhead of typing a long name.
Feb 15 2010
dsimcha:I tend to prefer short names for frequently used language and library constructs that everyone who has been using the language for more than two weeks should know. Longer names have their use in **your** programs and in less frequently used constructs, where the overhead of memorizing what a short, unclear name means is less than the overhead of typing a long name.
http://en.wikipedia.org/wiki/Zipf_law Bye, bearophile
Feb 15 2010
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
I never understood the reason for that the names need to be short. I think the most important thing is that the names are clear. Just look at the C standard library, it's horrible, almost every name is an abbreviation of some kind.
Are you trying to start a flame war? What's wrong with LISP's car and cdr? Isn't it obvious to all and sundry that car is the head element of a singly linked list and cdr is the rest of the list with the head element removed? Justin Johansson :-) :-) :-)
Feb 15 2010
On 02/15/2010 09:44 PM, Justin Johansson wrote:Isn't it obvious to all and sundry that car is the head element of a singly linked list and cdr is the rest of the list with the head element removed?
Actually, car is the reference to the first item in the cons cell, and cdr is the second. Not just lists, you know. :)
Feb 15 2010
On 15/02/2010 15:00, Jacob Carlborg wrote:On 2/14/10 18:18, Andrei Alexandrescu wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
I never understood the reason for that the names need to be short. I think the most important thing is that the names are clear. Just look at the C standard library, it's horrible, almost every name is an abbreviation of some kind.
C was designed in the dark ages when programmers actually tried to save bytes in their extremely limited hardware. That same age brought us the tab character, Y2k bug and FORTRAN.
Feb 16 2010
On 14/02/2010 19:18, Andrei Alexandrescu wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list. Andrei
As I said multitude of times before, if you want D to be commercially successful, you need to change your priorities. the *most* important thing to have is _clear_ and _understandable_ names by a wide international audience. The *least* important thing is shortness. you might argue as long as you want that C++/D is technically superior to Java, but fact remains that Java is the favorite language in enterprise. One huge factor which helps this is of course the clear naming scheme in its stdlib.
Feb 16 2010
On 14.02.2010 11:12, Jacob Carlborg wrote:On 2/14/10 09:14, Jonathan M Davis wrote:Though I must say that I find retro to be a bit funny. I would have expected it to be reverse. It would be clearer, I think, but it's not like it's hard to find out what retro does and remember it. - Jonathan M Davis
It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
foreach (thing; backwards(lotsOfThings)) { } 'backwards' would be fine by me. But then I don't seem to iterate in reverse a whole lot, so it doesn't bother me that it's twice a long as 'retro'. Is that really a problem?
Feb 15 2010
On Sun, Feb 14, 2010 at 02:26:36PM -0500, bearophile wrote:For me "retro" is acceptable.
I like it too. Retro style never even came to my mind; I thought of retro rockets - the rockets that fire in reverse. -- Adam D. Ruppe http://arsdnet.net
Feb 14 2010
"Igor Lesik" <curoles yahoo.com> wrote in message news:mailman.58.1266181553.4461.digitalmars-d puremagic.com...opposite not very long name, bears the meaning
"opposite" (and "inverse" as someone suggested) can have a lot of different meanings. Too ambiguous, IMO.
Feb 14 2010
Sun, 14 Feb 2010 11:18:02 -0600, Andrei Alexandrescu wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list.
It sounds like a flaw in the language design if the symbols for reversing arrays and ranges somehow conflict.
Feb 14 2010
Sun, 14 Feb 2010 14:26:36 -0500, bearophile wrote:Andrei Alexandrescu:I don't mind "reversed" but it's longer than "retro" and the convention doesn't scale. For example, both active and passive forms of "split" look the same.
For me "retro" is acceptable. I don't love "iota" but I can accept it too. Other names of Phobos2 can be improved.
Agreed, these names are really confusing. To me itoa sounds like "integer to string" and iota "string to integer" ("to".reverse == "ot"). I can imagine using retro in code such as: import pacman.PacmanGame; void main() { if (userWants3DVoodoo) { // real time 3d rendering with photon mapping and 9.1 192/24 sounds (new PacmanGame).start(); } else { // nice 8-bit graphics with mono 4-bit sound retro(new PacmanGame).start(); } }
Feb 14 2010
Andrei Alexandrescu Wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range. Andrei
What about where foreach is being done over something other than a range? eg. foreach(i; 1..100) foreach(v; structwithopapply)
Feb 14 2010
Daniel Murphy:What about where foreach is being done over something other than a range? eg. foreach(i; 1..100) foreach(v; structwithopapply)
The first can be done turning an interval into syntax sugar for iota(1,100): The foreach(i; retro(1 .. 100)) Otherwise the interval syntax can grow the step, as in Python and other languages (in D the step might even be a compile-time constant): The foreach(i; 1 .. 100 : -1) The second gives no problems if retro is well done: foreach(v; retro(structWithopApplyReverse)) Bye, bearophile
Feb 14 2010
The foreach(i; 1 .. 100 : -1)
Sorry, I meant: foreach(i; 99 .. 0 : -1) Bye, bearophile
Feb 14 2010
On 2010-02-14 07:15:55 -0500, bearophile <bearophileHUGS lycos.com> said:The first can be done turning an interval into syntax sugar for iota(1,100): The foreach(i; retro(1 .. 100))
I'm all for it, but we'll need to have 1..100 mapped to a new interval type for this to work. Then you can easily implement this (among many other interesting things): auto reverse(Interval!int interval) { ... } -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Feb 14 2010
== Quote from bearophile (bearophileHUGS lycos.com)'s articleThe second gives no problems if retro is well done: foreach(v; retro(structWithopApplyReverse)) Bye, bearophile
I have no idea how you would implement retro such that it worked with opApplyReverse.
Feb 14 2010
== Quote from Daniel Murphy (yebbliesnospam gmail.com)'s articleAndrei Alexandrescu Wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range. Andrei
eg. foreach(i; 1..100) foreach(v; structwithopapply)
In general, now that we've decided to keep opApply, std.range needs to be reworked a little to make it coexist as peacefully as possible with ranges. For this case, I guess retro could simply have an opApply method that forwards to structwithopapply's opApplyReverse method.
Feb 14 2010
Andrei Alexandrescu wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range.
Let me first say that I think it's great that one of D's ugliest keywords is going away. But does retro (or ranges in general) support iteration over both index and element? foreach_reverse(i, e; foo) { ... } -Lars
Feb 14 2010
Lars T. Kyllingstad wrote:Andrei Alexandrescu wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range.
Now all what's left to do is to make it as efficient as the builtin functionality.Let me first say that I think it's great that one of D's ugliest keywords is going away. But does retro (or ranges in general) support iteration over both index and element? foreach_reverse(i, e; foo) { ... }
And will it be able to parse utf-8 backwards? I assume proper utf-8 support with ranges (or whatever is planned) isn't implemented yet, so I didn't test it.-Lars
Feb 14 2010
== Quote from Lars T. Kyllingstad (public kyllingen.NOSPAMnet)'s articleAndrei Alexandrescu wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range.
keywords is going away. But does retro (or ranges in general) support iteration over both index and element? foreach_reverse(i, e; foo) { ... } -Lars
Bug 3519: http://d.puremagic.com/issues/show_bug.cgi?id=3519
Feb 14 2010
Andrei Alexandrescu Wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range. Andrei
I think Reverse would have been a better title. Retro sounds like you might be using only 8088 assembler instructions in the output... -=mike=-
Feb 14 2010
Mike James Wrote:Andrei Alexandrescu Wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range. Andrei
I think Reverse would have been a better title. Retro sounds like you might be using only 8088 assembler instructions in the output... -=mike=-
Read about a guy that used preprocessor to change C keywords to his taste on company project. Nearly caused heart attack to next guy in line to maintain that code. Maybe we could keep both keywords :D
Feb 14 2010
Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
Agree. My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear). -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ----------------------------------------------------------------------
Feb 14 2010
Andrei Alexandrescu, el 14 de febrero a las 11:18 me escribiste:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be
I'm not trying to hurt you :) I just pointing out that you sometimes pick up clever or creative or niche names, which might look like a good idea to you but it's not for me. They are different points of view, I'm sure a lot of people would "look, D has these very clever names, it sure is a good language", but I think, from a practical point of view, that it's a bad idea because they are less natural and harder to learn, remember and *read*.of course best if names that arguably hurt the language were changed, so please compile a list.
Well, they were discussed several times, sometimes with huge threads (like the range methods names). iota() is another really hard to remember/understand name for me (I said that before). I just didn't know what iota() was before you used it in phobos. I even couldn't follow some examples before I searched what iota was (which it took me some time because I was a little embarrassed that I didn't knew its meaning =). -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ----------------------------------------------------------------------
Feb 15 2010
Andrei Alexandrescu, el 14 de febrero a las 12:08 me escribiste:bearophile wrote:Mike James:1. Contrawise 2. Rearward 3. AssBackwards 4. Reorientated 5. Turnedabout 6. Turnedaround 7. Inversified 8. Flipped 9. Refluxed 10. VolteFace or how about Reverse...
Wonderful, I elect you the official namer for Phobos :-) And I think Andrei meant a list of all the bad names in Phobos :-) What about "reversed"? :-)
I don't mind "reversed" but it's longer than "retro" and the convention doesn't scale. For example, both active and passive forms of "split" look the same.
Well, english sucks, you can't fix that ;) -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ----------------------------------------------------------------------
Feb 15 2010
Andrei Alexandrescu, el 14 de febrero a las 20:24 me escribiste:retard wrote:Sun, 14 Feb 2010 11:18:02 -0600, Andrei Alexandrescu wrote:Leandro Lucarella wrote:Michel Fortin, el 14 de febrero a las 07:48 me escribiste:On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob me.com> said:It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
My dictionary says: "retro": imitative of a style, fashion, or design from the recent past. It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
(the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list.
It sounds like a flaw in the language design if the symbols for reversing arrays and ranges somehow conflict.
There are two operations: reverse the thing in place, and span it in retrograde order.
I think reverse (in-place) and reversed (returns a range that iterates in reverse order) are *very* clear in terms of that distinction. -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ----------------------------------------------------------------------
Feb 15 2010
On Sun, 14 Feb 2010 00:53:31 -0500, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:Gone, that is. Walter agreed to remove it. To achieve the functionality of foreach_reverse (r) { ... } use foreach (retro(r)) { ... } using retro in std.range.
Will retro work on AA's? Other than that (and how to do foreach(1..100) that others have brought up) I think this is a great move. BTW, for those bemoaning the loss of opApplyReverse, it is easy to change this: struct S(T) { int opApplyReverse(int delegate(ref T t) dg) {...} } S!int s; foreach_reverse(i; s) {...} into this: struct S(T) { int inReverse(int delegate(ref T t) dg) {...} } S!int s; foreach(i; &s.inReverse){...} Of course, I'd prefer it without the &, but that is a separate issue (see bug http://d.puremagic.com/issues/show_bug.cgi?id=2498) Also, while your attention is focused on foreach, look at this bug: http://d.puremagic.com/issues/show_bug.cgi?id=2443 :) -Steve
Feb 15 2010









Michel Fortin <michel.fortin michelf.com> 