I was working for a company once that did a lot of work with large numbers. It's hard, though, to write 45 billion as 45000000000. It's very hard to read.Let's change the compiler to accept the syntax 45b as 45 billion. (We could easily implement the billion unary message, but that doesn't compile to a literal which means we can't put it into an array literal).
The Smalltalk compiler in VisualWorks parses the numbers through the method Number class >> readSmalltalkSyntaxFrom:. In this method, we can change the line:
value := self readIntegerFrom: aStream radix: 10.
To:
value := self readIntegerFrom: aStream radix: 10.
(aStream peekFor: $b) ifTrue: [value := value * 1000000000].
(aStream peekFor: $m) ifTrue: [value := value * 1000000].
(aStream peekFor: $k) ifTrue: [value := value * 1000].
Now we can type 45b and get 45 billion. Typing 45m gives 45 million and 45k gives 45 thousand.
What if we want 4.5b to be 4.5 billion? We just change the float parsing. In the method Number class >> readSmalltalkFloat:from: change the line:
value := integerPart + (num / den). "The exponent will be added in the next step."
to:
value := integerPart + (num / den). "The exponent will be added in the next step."
(aStream peekFor: $b) ifTrue: [value := value * 1000000000].
(aStream peekFor: $m) ifTrue: [value := value * 1000000].
(aStream peekFor: $k) ifTrue: [value := value * 1000].
There you go. 4.5b (even in literal arrays) means 4.5 billion. How many languages allow you to do that?