REBOL3 tracker
  0.9.12 beta
Ticket #0001445 User: anonymous

Project:



rss
TypeBug Statustested Date24-Jan-2010 09:59
Versionalpha 96 CategorySyntax Submitted bySunanda
PlatformAll Severityminor Prioritynormal

Summary Whitespace requirements inconsistent with money! and operators
Description This works:
>> $1/$2
== $0.50000000000000000000000000

Other, seemingly equivalent operations do not:
>> $1*$2
** Syntax error: invalid "money" -- "$1*$2"

>> $1+$2
** Syntax error: invalid "money" -- "$1+$2"

>> $1-$2
** Syntax error: invalid "money" -- "$1-$2"

And this fails in two different ways:
>> $1 ** $2
** Script error: ** does not allow money! for its exponent argument

>> $1**$2
** Syntax error: invalid "money" -- "$1**$2"

Example code
Expect true here:
error? try [$1/$1]

Assigned ton/a Fixed inalpha 97 Last Update8-Feb-2010 03:33


Comments
(0001927)
meijeru
24-Jan-2010 10:47

Seems to me the problem is the special treatment of / . It is the only one that works without spaces since the lexical scan pays special attention to it.

As an aside, the interdiction of exponentiation is somewhat debatable, in my view, but this would warrant another ticket.

As another aside, I would submit that having $1 / $2 give a result of type money! goes against my "physical intuition" -- if the money! type really means money (i.e. quantity + denomination), the quotient should be a dimensionless number, i.e. of decimal! type. Compare 0.5 * $2 == $1. On the other hand, the money! type practically means nothing more than "having a precise decimal representation". That might warrant a change of the type name if the consequences were not too heavy...
(0001948)
Carl
4-Feb-2010 13:31

Fixed, and also noticed and fixed the similar 1.2/abc case.

Meijeru: yes, it's the datatype literal designation. There are very few characters available as alternates, and it's a legacy issue. Programmers should understand $123 to be precise decimal datatype. The $ does not represent a unit, but a method of computation.

Date User Field Action Change
8-Feb-2010 03:33 BrianH Status Modified built => tested
4-Feb-2010 13:42 carl Comment : 0001948 Modified -
4-Feb-2010 13:34 carl Status Modified reviewed => built
4-Feb-2010 13:34 carl Fixedin Modified => alpha 97
4-Feb-2010 13:34 carl Comment : 0001948 Modified -
4-Feb-2010 13:31 carl Comment : 0001948 Added -
29-Jan-2010 23:00 BrianH Version Modified alpha 97 => alpha 96
29-Jan-2010 23:00 BrianH Status Modified submitted => reviewed
29-Jan-2010 23:00 BrianH Category Modified Error Handling => Syntax
29-Jan-2010 23:00 BrianH Code Modified -
29-Jan-2010 23:00 BrianH Description Modified -
29-Jan-2010 23:00 BrianH Summary Modified whitespace requirements inconsistent with money maths => Whitespace requirements inconsistent with money! and operators
24-Jan-2010 11:02 meijeru Comment : 0001927 Modified -
24-Jan-2010 10:51 meijeru Comment : 0001927 Modified -
24-Jan-2010 10:50 meijeru Comment : 0001927 Modified -
24-Jan-2010 10:49 meijeru Comment : 0001927 Modified -
24-Jan-2010 10:47 meijeru Comment : 0001927 Added -
24-Jan-2010 09:59 sunanda Ticket Added -