Does D have too many features?

Timon Gehr timon.gehr at gmx.ch
Mon Apr 30 11:37:41 PDT 2012


On 04/30/2012 08:30 PM, Alex Rønne Petersen wrote:
> On 30-04-2012 20:17, Timon Gehr wrote:
>> On 04/30/2012 05:21 PM, Alex Rønne Petersen wrote:
>>> On 30-04-2012 08:37, jerro wrote:
>>>>> Sorry, I managed to get myself confused here. What I meant to say was
>>>>> that I think >> should do an arithmetic shift if the operands are
>>>>> signed; unsigned shift otherwise.
>>>>
>>>> It does arithmetic shift if the left operand is signed,
>>>> unsigned shift otherwise. This code:
>>>>
>>>> void main()
>>>> {
>>>> int a = 0xffffffff;
>>>> uint b = a;
>>>> writefln("%x", a >> 1);
>>>> writefln("%x", b >> 1);
>>>> }
>>>>
>>>> prints
>>>>
>>>> ffffffff
>>>> 7fffffff
>>>>
>>>
>>> The documentation disagrees:
>>> http://dlang.org/expression.html#ShiftExpression
>>>
>>> It claims that it always does arithmetic shift and >>> always does
>>> unsigned shift.
>>>
>>
>> http://d.puremagic.com/issues/show_bug.cgi?id=8007
>
> Thanks; these kinds of documentation bugs can cause really nasty
> misunderstandings.
>

I don't trust the documentation. In my experience, it is usually best to 
rely on common sense to get a grasp for how a feature is supposed to 
behave (that works surprisingly well!) and occasionally file bug reports 
if either the documentation or DMD is strange in a certain aspect. (I'll 
probably file a bunch of implicit-conversion related bugs tomorrow.)


More information about the Digitalmars-d mailing list