If Scheme is so good why MIT drops it?

vippstar vippstar at gmail.com
Mon Jul 20 14:31:08 EDT 2009


On Jul 20, 7:50 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> vippstar <vipps... at gmail.com> writes:
> > > I wonder whether 2/3 => ValueError is preferable.
>
> > Not all software wants this. It shouldn't be part of the language but
> > rather part of your code if you need such a feature. (for instance, to
> > distinguish between 2/3 and divisions with 0 dividend).
>
> I don't see how to implement such a thing in my code,
Write a function:

  (if (< x y)
      ValueError
      (/ x y))

This will return 0 only if the dividend = 0, not in integer division x/
y with y > x, which will return ValueError. Of course, ValueError must
not be an integer, because that could be the result of an integer
division. If it's not possible to return multiple types, then the
function can make use of some error handling mechanism.

> if I believe that the ring of integers doesn't have any concept
> of division and so attempts to divide integers should be treated
> as errors.

Wouldn't that mean 3/2 would also evaluate to ValueError? But 3/2 = 1
in integer division, not 0, like 2/3. Regardless, it's a specialized
requirement, and thus should either be implemented by the programmer
or the language could provide it if it's specialized, (for instance, I
wouldn't require a language to provide text manipulation features, but
I expect them from perl because it's not a general all purpose
language [the name designates that, however it can be used as one -
like lisp])

> course the present / operator is useful, but I could do just as well
> with the divmod function which I think is more explicit.
What? Python? Aww.



More information about the Python-list mailing list