January 12, 2011 Re: D standard style [was: Re: eliminate junk from std.string?] | ||||
|---|---|---|---|---|
| ||||
Posted in reply to spir | On 2011-01-11 20:28:27 -0500, spir <denis.spir@gmail.com> said: > But while we're at conventions, and before any change is actually done, we may take the opportunity to agree not only on morphology, but on semantics ;-) > > For instance, from online doc: > string capitalize(string s); > Capitalize first character of string s[], convert rest of string s[] to lower case. > Then, use it: > auto s = "capital"; > s.capitalize(); > writeln(s); // "capital" > Uh? > Not only the name is misleading, but the doc as well. > > For this kind of issue, some guidelines read like: > * perform an action --> action verb (eg capitalise: changes the passed string) > * return a result --> named after result (eg capitalised: return new string) > Sure, the func's interface also tells the reader what's actually done. But having name (and doc) contradict it is not very helpful. And beeing forced to open the doc or even the source for every unknown bit is an annoying obstacle. > > There are probably other common issues like this. My personal evaluation is whether some newcomer can guess the purpose of the func, the type, the constant, etc... > > I would also vote for: > * full words, except for rare exception used everywhere in programming _and_ really helpful (eg OS) > * get rid of obscure, ambiguous, or misleading namings > * when possible, use international words rather than english-only (eg section better than slice if everything else equal) I support this too. Names should be easy to read. That said, I'm not exactly sure about what you mean by this "use international words" recommendation. I really don't get why "section" would be better than "slice". Words that exists in other languages don't always have the exact same meaning as in English, so they might also be more confusing to an international audience. I'd stick with the "choose a meaningful word" rule. -- Michel Fortin michel.fortin@michelf.com http://michelf.com/ | |||
January 12, 2011 Re: eliminate junk from std.string? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 2011-01-11 18:00:51 -0500, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> said: > On 1/11/11 11:21 AM, Ary Borenszweig wrote: >> Why care where they come from? Why not make them intuitive? Say, like, "Always >> camel case"? > > If there's enough support for this, I'll do it. I support this. -- Michel Fortin michel.fortin@michelf.com http://michelf.com/ | |||
January 12, 2011 Re: eliminate junk from std.string? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | "Andrei Alexandrescu" <SeeWebsiteForEmail@erdani.org> wrote in message news:iginid$1rtg$2@digitalmars.com... > On 1/11/11 11:21 AM, Ary Borenszweig wrote: >> Why care where they come from? Why not make them intuitive? Say, like, >> "Always >> camel case"? > > If there's enough support for this, I'll do it. > I've already been arguing in favor of it :) vote++; | |||
January 12, 2011 Re: eliminate junk from std.string? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 12/01/11 10:00, Andrei Alexandrescu wrote:
> On 1/11/11 11:21 AM, Ary Borenszweig wrote:
>> Why care where they come from? Why not make them intuitive? Say, like,
>> "Always
>> camel case"?
>
> If there's enough support for this, I'll do it.
Yes please; it's got my vote.
| |||
January 12, 2011 Re: eliminate junk from std.string? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu wrote:
> On 1/11/11 11:21 AM, Ary Borenszweig wrote:
>> Why care where they come from? Why not make them intuitive? Say, like, "Always camel case"?
>
> If there's enough support for this, I'll do it.
>
> Andrei
+1
| |||
January 12, 2011 Re: eliminate junk from std.string? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Tue, 11 Jan 2011 15:00:51 -0800, Andrei Alexandrescu wrote:
> On 1/11/11 11:21 AM, Ary Borenszweig wrote:
>> Why care where they come from? Why not make them intuitive? Say, like, "Always camel case"?
>
> If there's enough support for this, I'll do it.
>
> Andrei
++vote
IMO, this should be done throughout Phobos before it's too late.
-Lars
| |||
January 12, 2011 Re: eliminate junk from std.string? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 2011-01-12 00:00, Andrei Alexandrescu wrote: > On 1/11/11 11:21 AM, Ary Borenszweig wrote: >> Why care where they come from? Why not make them intuitive? Say, like, >> "Always >> camel case"? > > If there's enough support for this, I'll do it. > > Andrei vote++ -- /Jacob Carlborg | |||
January 12, 2011 Re: eliminate junk from std.string? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu wrote:
> On 1/11/11 11:21 AM, Ary Borenszweig wrote:
>> Why care where they come from? Why not make them intuitive? Say, like, "Always
>> camel case"?
>
> If there's enough support for this, I'll do it.
>
> Andrei
++vote.
Bear in mind that with D's spell checker, the error message is:
test.d(8): Error: undefined identifier tolower, did you mean function toLower?
Which is pretty darn good.
| |||
January 12, 2011 Re: eliminate junk from std.string? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu Wrote:
> If there's enough support for this, I'll do it.
>
> Andrei
for how much it can be worth, +1
Paolo
| |||
January 12, 2011 Re: eliminate junk from std.string? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Wed, 12 Jan 2011 08:00:51 +0900, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote: > On 1/11/11 11:21 AM, Ary Borenszweig wrote: >> Why care where they come from? Why not make them intuitive? Say, like, "Always >> camel case"? > > If there's enough support for this, I'll do it. ++vote :) Masahiro | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply