Naming of new lazy versions of existing Phobos functions

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 20 03:19:08 PDT 2014


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


More information about the Digitalmars-d mailing list