--- Comment #5 from 2012-09-16 17:06:26 PDT ---
(In reply to comment #4)
> The point is, the programmer has to take "extra care" regardless.

I am not the only one making mistakes with the C-style modulus, I know of other
people that have had similar bugs. And I know teachers of C/Java languages that
have to take care of explaining the not intuitive nature of the C modulus.

But as usual I don't have real statistics that show that the Python-style
modulus leads to less bugs.

> It may be natural for your particular code example,

What I have shown is not an arbitrary and very specific example, it's an
example of a common usage. 

> The diversity of definitions for it strongly suggests that there is no
> "natural" defintion.

That's the not-adaptationist explanation
( ). An alternative explanation is
that they are just copying the semantics from precedent (C, Algol?) designs.
In the case of D the explanation is that it has copied C99, for practical
backward compatibility purposes. It's a scan of a cyclic structure (a cirular
array), where sometimes you go forward and sometimes you go backward, with
negative steps. While the presence of an array is specific, the need to walk
circular sequences is a common enough use case for the modulus among negative

> D improves on the C/C++ situation by making it defined behavior, rather than
> undefined.

C makes its behavour defined since C99 :-)

I will keep using my function in D, because it has avoided me some bugs. Thank
you for your answers.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to