From: Mathieu Bouchard Date: 2000-06-08T01:42:19-04:00 Subject: [ruby-talk:03180] Re: Is divmod dangerous? > Integer#divz, which truncates towards zero. Associated with these are > corresponding modulo routines, #mod (the current behavior) and #modz > (which is equivalent to remainder). > Then, we have two 'personalities', which are actually just modules. > include ZeroTrunc > aliases Integer#/ to divz and Integer#% to #modz > include SchemeTrunc > does the opposite > Have ZeroTrunc be the default, but allow people to load SchemeTrunc > for the traditional behavior. > Library routines which can potentially run in either environment > should use the underlying .div and .divz routines. This leads to either inflexible code or the default division operator to be condemned. Perl once did that with base array index variable $[ so that people can choose either the C style 0..n-1 indices or Ada style 1..n; this is now widely regarded as bad style, especially since the fast raise in the number of publicly available modules. Some versions of Basic had a similar OPTION BASE thing that was similarly unused, and became even less used in more structured versions of Basic. Following my observations I think any person truly believing in modularity will religiously avoid such compromises. To me, rounding towards the bottom is the right thing; and i can live with rounding towards zero as long as there's an alternative, albeit slightly longer to type. But i would certainly not like the compromise you suggest. Mathieu Bouchard