Design of intuitive interfaces

Jacob Carlborg doob at me.com
Sun Feb 21 13:59:28 PST 2010


On 2010-02-21 21.06, Nick Sabalausky wrote:
> "Jacob Carlborg"<doob at me.com>  wrote in message
> news:hlrk2c$2kq7$2 at digitalmars.com...
>> On 2/21/10 16:19, bearophile wrote:
>>> Michel Fortin:
>>>> array.sort(predicate)     // sort in place using predicate
>>>> array.sorted(predicate)   // create sorted copy using predicate
>>>> array.isSorted(predicate) // tell if the array is sorted using predicate
>>>
>>> Good.
>>>
>>> Another possibility is to let D2 accept ? and ! too inside variable
>>> names, so they can become (as in Ruby I think, and something similar is
>>> common in Lisp-like languages too):
>>> array.sort(predicate)
>>> array.sort!(predicate); // void function
>>> array.sorted?(predicate)
>>>
>>> Bye,
>>> bearophile
>>
>> I never liked that with ruby, I would prefer Michel Fortin's suggestion.
>
> I'm surprised to hear that. I always thought it was very clean and more
> generally-useful than things like isBlah (I've frequently run into cases
> where the isBlah couldn't be used as it would have resulted in a gibberish
> variable name). Only problem I ever saw with it is that it's not a realistic
> possibility in D due to ambiguities with other parts of D's syntax.

Maybe it's because typing a ? or ! doesn't fit as good in my hands 
compared to other characters, this is using a swedish which requires two 
keys to be pressed. I think using the "is" prefix makes it more like 
english if you read it, for example, I read "if(array.isSorted)" as "if 
array is sorted".




More information about the Digitalmars-d mailing list