Naming of new lazy versions of existing Phobos functions

Gary Willoughby via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 19 02:13:25 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.

I think it is worth while having this discussion even though it 
does seem like we're bike shedding. These names will be set in 
stone for the foreseeable future so having a quick upfront 
discussion is worth it IMHO.

As for the above proposed names i really like these names a lot. 
I think they offer a good convention for lazy versions *and* they 
sit nearby in the documentation.


More information about the Digitalmars-d mailing list