Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Numbers, Scheme style

Name: Anonymous 2015-01-14 18:02

What would Scheme be like if numbers followed the same style as the rest of the language?

It would be necessary to import a library before using any numbers.

(import (scheme numbers))

Numeric constants would be provided as functions returning the constant, apparently because the section of RNRS they appear in is called “Standard Procedures”. Only the most basic constants would be provided; pi would not be among them.

(define (exact-rational-zero)
(make-exact-rational (exact-integer-zero) (exact-integer-one)))


Numbers would have no printed representation. Creating them would require explicit constructor calls.

There would be no polymorphism. Most operations would include a type in their name.

(define (factorial n)
(if (exact-integer<=? n (exact-integer-one))
(exact-integer-one)
(exact-integer-multiply! (factorial (exact-integer-subtract n (exact-integer-one))) n)))


The distinction between exact and inexact numbers would still be supposedly “orthogonal to the dimension of type”. But the lack of polymorphism would make it even more obvious that in practice exactness was simply one of the type distinctions: that between floats and everything else.

Floating-point numbers would be called “inexact rationals”. Their constructor would take a numerator and denominator, just like exact rationals; their floating-point representation would be considered an implementation detail. Various details of the specification would be inconsistent with IEEE floating point.

http://arcanesentiment.blogspot.ru/2015/01/if-scheme-were-like-scheme.html

Name: sage 2015-01-14 18:19

go away BLOGGER

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List