const and phobos string functions

Daniel Keep daniel.keep.lists at gmail.com
Thu Aug 2 05:45:36 PDT 2007



Regan Heath wrote:
> Instead perhaps we need a naming convention for inplace modifying
> functions, options:
> 
> void <func>Inplace(<args>)
> void <func>IP(<args>)       // "IP" stands for inplace
> void <func>M(<args>)        // "M" stands for mutates
> 
> or something like those.
> 
> Regan

I actually tried doing this in a math library of mine, but I didn't like
using normal letters; I wanted to use a Unicode character that was easy
to type, showed up in Vim, and would visually distinguish the functions.

Sadly, all I could come up with[1] for "in place" was '¶', and the
compiler didn't like that :(

Sometimes, I wonder if it wouldn't help a lot to be able to define
function overloads based on argument decoration.  So, you could have
something like:

  tolower(str);
  tolower(inplace str);
  tolower(takecopy str);

There are so many times where you have several functions that do the
exact same thing (semantically speaking), but have different
implementations.

Maybe I could fake it with structs...

struct tolower
{
    string opCall(string str);
    void inplace(char[] str);
    char[] takecopy(char[] str);
    char[] takecopy(string str);
}

Something to think about, anyway...

	-- Daniel

[1] That's what you get if you type ^KIP in Vim.  If you type ^Kip, you
get 'ぴ', and ^KiP is 'ピ' :P



More information about the Digitalmars-d mailing list