July 19, 2014 Re: Naming of new lazy versions of existing Phobos functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brad Anderson | On Saturday, 19 July 2014 at 00:05:55 UTC, Brad Anderson wrote:
> To summarize what I think are the best ideas so far:
>
> std.string
> ----------
>
> Eager Lazy
> ----- ----
> capitalize capitalized
> center centered
> detab detabbed
> entab entabbed
> format formatted
> leftJustify leftJustified
> munch munched
> outdent outdented
> removechars charsRemoved
> rightJustify rightJustified
> splitLines (none, uses splitter)
> squeeze squeezed
> strip stripped
> stripLeft leftStripped
> stripRight rightStripped
> succ successor
> toLower lowercased
> toStringz nullTerminated
> toUpper uppercased
> translate translated
> wrap wrapped
>
> std.path
> --------
>
> Eager Lazy
> ----- ----
> absolutePath absolutePathOf *
> buildNormalizedPath asNormalizedPath *
> buildPath asPath *
> defaultExtension withDefaultExtension *
> dirName dirNameOf *
> driveName driveNameOf *
> expandTilde tildeExpanded
> relativePath relativePathOf *
> setExtension withExtension
> stripDrive driveStripped
> stripExtension extensionStripped
>
> * - not terribly happy with these but I'd say it's the best of what's been proposed
>
> Generally it seems like past tense works when the function has a verb, "with" prefix when there is no verb but you are modifying something about the input, and "Of" suffix when you are pulling something out. Also, the verb should come last because it has a better ring to it.
I like this list.
|
July 19, 2014 Re: Naming of new lazy versions of existing Phobos functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brad Anderson | 19-Jul-2014 04:05, Brad Anderson пишет: > To summarize what I think are the best ideas so far: > > std.string > ---------- > > Eager Lazy > ----- ---- > capitalize capitalized > center centered > detab detabbed > entab entabbed > format formatted > leftJustify leftJustified > munch munched > outdent outdented > removechars charsRemoved > rightJustify rightJustified > splitLines (none, uses splitter) > squeeze squeezed > strip stripped > stripLeft leftStripped > stripRight rightStripped > succ successor > toLower lowercased > toStringz nullTerminated > toUpper uppercased > translate translated > wrap wrapped > > std.path > -------- > > Eager Lazy > ----- ---- > absolutePath absolutePathOf * > buildNormalizedPath asNormalizedPath * > buildPath asPath * > defaultExtension withDefaultExtension * > dirName dirNameOf * > driveName driveNameOf * > expandTilde tildeExpanded > relativePath relativePathOf * > setExtension withExtension > stripDrive driveStripped > stripExtension extensionStripped > > * - not terribly happy with these but I'd say it's the best of what's > been proposed > > Generally it seems like past tense works when the function has a verb, > "with" prefix when there is no verb but you are modifying something > about the input, and "Of" suffix when you are pulling something out. > Also, the verb should come last because it has a better ring to it. +1 -- Dmitry Olshansky |
July 20, 2014 Re: Naming of new lazy versions of existing Phobos functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brad Anderson | On Saturday, 19 July 2014 at 00:05:55 UTC, Brad Anderson wrote:
> To summarize what I think are the best ideas so far:
>
> std.string
> ----------
>
> Eager Lazy
> ----- ----
> capitalize capitalized
> center centered
> detab detabbed
> entab entabbed
> format formatted
> leftJustify leftJustified
> munch munched
> outdent outdented
> removechars charsRemoved
> rightJustify rightJustified
> splitLines (none, uses splitter)
> squeeze squeezed
> strip stripped
> stripLeft leftStripped
> stripRight rightStripped
> succ successor
> toLower lowercased
> toStringz nullTerminated
> toUpper uppercased
> translate translated
> wrap wrapped
>
> std.path
> --------
>
> Eager Lazy
> ----- ----
> absolutePath absolutePathOf *
> buildNormalizedPath asNormalizedPath *
> buildPath asPath *
> defaultExtension withDefaultExtension *
> dirName dirNameOf *
> driveName driveNameOf *
> expandTilde tildeExpanded
> relativePath relativePathOf *
> setExtension withExtension
> stripDrive driveStripped
> stripExtension extensionStripped
>
> * - not terribly happy with these but I'd say it's the best of what's been proposed
>
> Generally it seems like past tense works when the function has a verb, "with" prefix when there is no verb but you are modifying something about the input, and "Of" suffix when you are pulling something out. Also, the verb should come last because it has a better ring to it.
Do we really want to be naming functions which aren't properties with adjectives instead of verbs? That seems very wrong to me. I'd much rather see stuff like setExt or setExtLazy than withExtension or extensionSet. Function names are supposed to be verbs unless they're emulating variables. They _do_ something, even if it's lazy.
- Jonathan M Davis
|
July 20, 2014 Re: Naming of new lazy versions of existing Phobos functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Sunday, 20 July 2014 at 10:19:10 UTC, Jonathan M Davis wrote:
> Do we really want to be naming functions which aren't properties with adjectives instead of verbs?
Yes. We have parens for denoting functions.
Oh wait.
|
July 20, 2014 Re: Naming of new lazy versions of existing Phobos functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis |
> Do we really want to be naming functions which aren't properties with adjectives instead of verbs? That seems very wrong to me. I'd much rather see stuff like setExt or setExtLazy than withExtension or extensionSet. Function names are supposed to be verbs unless they're emulating variables. They _do_ something, even if it's lazy.
>
> - Jonathan M Davis
I think it is appropiate to use adjectives for lazy functions. The "Use verbs for functions"-rule holds no ground in lazy evaluation, except you want to call them "wrapInExtensionSetter" or something like that.
|
July 21, 2014 Re: Naming of new lazy versions of existing Phobos functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Friday, 18 July 2014 at 20:35:33 UTC, Walter Bright wrote:
> On 7/18/2014 12:40 PM, Tourist wrote:
>> Are you planning to deprecate the non-lazy functions at some (maybe very
>> distant) point?
>
> No. Phobos has already gone through multiple rounds of renaming/deprecation, all at considerable disruption. Each one was supposed to be "worth it" and the "last time". It needs to stop.
Is an alternate module an option? std.string.lazy, etc.
|
Copyright © 1999-2021 by the D Language Foundation