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

Pages: 1-

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

Name: Anonymous 2015-01-14 18:36

>>2
But I have no blogs.

Name: Anonymous 2015-01-14 18:47

Operations more obscure than exponent would be left to SRFIs. Users would be able to choose between the widely supported SRFI and the complete SRFI.

Winner.

Name: Anonymous 2015-01-14 18:50

news.ycombinator.com

Name: Anonymous 2015-01-14 19:20

>>5
What's that?

Name: Anonymous 2015-01-14 20:59

>>6
A triple quote of a URL, most likely generated by a spambot.

Name: Anonymous 2015-01-15 2:02

>>1
Or you could make + - * etc methods as they should be.

Name: Anonymous 2015-01-15 2:10

>>8
Scheme doesn't have methods.

Name: Anonymous 2015-01-15 2:17

>>9
It does if you implement an object system and a syntax for it with macros.

Name: Anonymous 2015-01-15 2:20

>>10
Not in DA STANDARD.

Name: Anonymous 2015-01-15 2:22

>>11
But the oo library is standard compliant.

Name: Anonymous 2015-01-15 4:16

>>12
The OO library is a standard complaint.

Name: Anonymous 2015-01-15 17:09

>>12
But it's still a library and DA STANDARD cannot depend on a library.

Name: Anonymous 2015-01-15 22:06

BOB THE ISO COMMITTEEE CAN WE FIX IT?
BOB THE ISO COMMITTEEE YES WE CAN AND ADD A WHOLE LOT OF OTHER USELESS SHIT TOO!

Name: Anonymous 2015-01-16 3:14

>>14
It doesn't need to be in the standard...
It's a library, that is standard compliant, and hence portable...
So you can use it on any scheme that respects the standard...

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