On Fri, Dec 11, 2015 at 3:02 PM, Brent Royal-Gordon
<br...@architechies.com> wrote:
>>> while I was working on this PR I encountered unexpected behavior from 
>>> Array.description. It iterates over its items and calls debugDescription on 
>>> them. I found it a bit unexpected thus my question here. Is it desired 
>>> behavior? I would expect description and debugDescription call respective 
>>> methods on the contents.
>>
>> Array's description shouldn't be presented to the user in raw form, ever, so 
>> the use case here is debugging.  Thus, it makes sense to present the debug 
>> representation of the elements in both cases.
>
> I keep noticing threads where people are confused about this kind of 
> thing—I’ve seen it with Array, Optional, and several others. I wonder if 
> these kinds of types simply *shouldn’t* offer .description properties, as a 
> way of saying “no user-visible conversion inside”.

Nobody should be using '.description' or '.debugDescription' directly
in any case.  One should be using String(x) or String(reflecting: x),
because that works with any instances, including those cases when the
runtime will synthesize the string representation for you.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to