(non)nullable types

Nick Sabalausky a at a.a
Sat Feb 14 12:05:17 PST 2009


"Yigal Chripun" <yigal100 at gmail.com> wrote in message 
news:gn771i$ded$1 at digitalmars.com...
>
> Besides, such a change will allow us to remove the ugly ?: operator and 
> will free the ? sign.
>

I like the ?: operator :-). It's short. But I agree it might be worth 
switching to an expression "if...else..." if that meant we could do the 
following...

> One of my favorite Ruby features (besides Blocks) is that Ruby allows 
> using ? and ! as part of identifiers. This is used in Ruby by convention 
> to represent methods that answer questions, and methods that are more 
> "dangareous" like in-place modification of data.
>
> so you can write:
> if (range.more?) ..

When I was looking into Ruby, I was impressed by this too. I had always 
liked MS's convention of prepending "is" to flags, but that only works on 
certain flags (sometimes you really mean "has" or "exists" or "capable of" 
something else besides "is"). Appending "?" is much more general.

> and it also has array.sort vs. array.sort! where the former gives a sorted 
> copy and the latter sorts in-place.

It would be kind of handy to have a nice simple convention for in-place vs 
non-inplace functions. Obviously "!" wouldn't work for D though, unless we 
were masochistic enough to revisit the old "What syntax to use for 
templates?" issue. 





More information about the Digitalmars-d mailing list