String Basics

Mike Parker aldacron71 at yahoo.com
Sat Jul 22 18:44:01 PDT 2006


Kent Boogaart wrote:

> 2. string-specific functions can be added to the string type. I'm a complete D
> noob so forgive any misinformation here. Currently I understand there to be a
> separate module for string-related functions. To me, there should be a string
> type that defines those functions:
> 
> char[] upper = toupper(myString);
> 
> versus:
> 
> string upper = myString.toupper();

You can do that now:

char[] myString = "myString";
cahr[] upper = myString.toupper();

> 
> The latter seems like much better OO design to me. 

Don't forget that D supports the procedural programming paradigm as 
well. Object Orientation has benefits, but is not a panacea. In my 
opinion, it shouldn't matter whether or not standard library APIs use OO 
design priniciples, as it generally does not affect the design of user 
code. Besides which, OO does not necessarily mean 'classes'. There are 
plenty of free function APIs that follow the OO paradigm. OpenGL is a 
great example. IMO, the need for a string class in D is imaginary. I 
have no use for one.



More information about the Digitalmars-d-learn mailing list