Why is array truth tied to .ptr?

Daniel Keep daniel.keep.lists at gmail.com
Mon Dec 10 18:37:47 PST 2007



Robert Fraser wrote:
> Daniel Keep wrote:
>> [2] Sometimes, I really wish '?' and '!' were valid characters in
>> identifiers, like in Ruby.
> 
> That gives me the answer to the Object.toString() vs. Object.toUtf8()
> problem posed before... just change it to Object.wtf?()

'?' is used for function that check a property of a type, '!' is used
for functions that perform in-place modification.

if( "my string".empty? )

[3,1,2].sort  --> int[]
[3,1,2].sort! --> void

Without "?", you can get away by putting "is" in front of everything,
but "!" is a hard one, unless you come up with some sort of trailing
sigil using normal characters (like _ip).

	-- Daniel



More information about the Digitalmars-d mailing list