A new class -->String

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Wed Apr 4 13:29:50 PDT 2007


David B. Held wrote:
> jinheking wrote:
>> I want to make a Class like java's String Class.
>> [...]
> 
> Well, I believe the intention is that when 'invariant' gets added to the
> language, we will get string thusly:
> 
> alias invariant char[] string;
> 
> Note that this leaves out all of the member functions that one expects
> from String.  However, with immutable strings, it is perfectly safe
> (and, perhaps, preferable) to implement all that functionality as free
> functions.  If there were a way to switch between method call and free
> function syntax, then this distinction would become moot (and maybe we
> will get that as well...).

D has that already :)

char[] moo;

void doSomething(char[] baa) {
	...
}

void main() {
	moo.doSomething();
}



More information about the Digitalmars-d mailing list