Adobe position paper on the ECMAScript 4 proposal space -- decimal

Lars Hansen lhansen at adobe.com
Thu Feb 28 06:43:49 PST 2008


> -----Original Message-----
> From: Dick Sweet 
> Sent: 27. februar 2008 23:27
> To: Lars Hansen; 'Peter Hall'
> Cc: 'Brendan Eich'; 'es4-discuss Discuss'; 'TC39'; 'Mike Cowlishaw'
> Subject: RE: Adobe position paper on the ECMAScript 4 
> proposal space -- decimal
> 
> Lars is correct.  If you can declare decimal literals, that 
> is enough to get you into decimal arithmetic.  The various 
> automatic coercions will do the rest, though as he said, type 
> annotations could reduce the scope of errors.  You would also 
> need some static methods on decimal like exp and log, since 
> the ones on Number expect doubles.

The current thinking for ES4 is that all the Math methods are
polymorphic and would return decimal results for decimal inputs (and int
results for int inputs when that makes sense).  There could be
corresponding monomorphic methods on double and decimal, too, of course,
but that's not been brought up.

> 
> Dick
> 
> -----Original Message-----
> From: Lars Hansen
> Sent: Wednesday, February 27, 2008 1:54 PM
> To: Peter Hall; Dick Sweet
> Cc: Brendan Eich; es4-discuss Discuss; TC39; Mike Cowlishaw
> Subject: RE: Adobe position paper on the ECMAScript 4 
> proposal space -- decimal
> 
> There's no such rule in ES4.  There are implicit conversions 
> among primitive number types, and between primitive types and 
> wrapper types, and those kick in when storing something in an 
> annotated location.  So these two programs are different, and 
> both are correct:
> 
>   var s = "foo"
>   var t = 10.5
> 
> and
> 
>   var s : String = "foo"
>   var t : int = 10.5
> 
> (Decimal makes sense without any type annotations, but 
> annotations probably cause coercions to decimal to happen 
> more often and thus reduce the scope for error.  I assume 
> this is what Dick meant.  But 1m would be a decimal value 1, 
> and 1m/10 would convert 10 to decimal before dividing -- no 
> annotations involved.)
> 
> --lars
> 
> > -----Original Message-----
> > From: es4-discuss-bounces at mozilla.org 
> > [mailto:es4-discuss-bounces at mozilla.org] On Behalf Of Peter Hall
> > Sent: 27. februar 2008 22:29
> > To: Dick Sweet
> > Cc: Brendan Eich; es4-discuss Discuss; TC39; Mike Cowlishaw
> > Subject: Re: Adobe position paper on the ECMAScript 4 
> proposal space 
> > -- decimal
> > 
> > OK. Decimal type just makes sense to me. And I think this 
> is one case 
> > where I think you can break "the rule" that says correct type 
> > annotations do not affect the program.
> > 
> > Peter
> > 
> > 
> > On Wed, Feb 27, 2008 at 9:10 PM, Dick Sweet <sweet at adobe.com> wrote:
> > > A couple of comments from the fellow who did the trial
> > implementation
> > > of  decimal in Tamarin.
> > >
> > >  It would be pretty easy to have decimal if you have to 
> explicitly 
> > > declare variables of that type and need to explicitly
> > denote literals
> > > that you want to be decimal with the "m" suffix.  Such denotation 
> > > would  not be necessary for literals without fractional
> > parts, unless
> > > they are  beyond the range of integer representation within
> > a double.  
> > > Promotion  of arithmetic to decimal in mixed situations
> > isn't that hard to do.
> > >
> > >  Dick
> > >
> > >
> > >  -----Original Message-----
> > >  From: Brendan Eich [mailto:brendan at mozilla.org]
> > >  Sent: Wednesday, February 27, 2008 10:58 AM
> > >  To: Peter Hall
> > >  Cc: es4-discuss Discuss; TC39; Mike Cowlishaw
> > >  Subject: Re: Adobe position paper on the ECMAScript 4
> > proposal space
> > > --  decimal
> > >
> > >
> > >
> > > On Feb 27, 2008, at 10:40 AM, Brendan Eich wrote:
> > >
> > >  > First, nothing's "ruled out" -- you're asking the wrong
> > guy if you
> > > > want Adobe's position, but see Lars's reply to Mike Cowlishaw:
> > >  > decimal as a type without any implicit literal/operators
> > mode is  >
> > > still possible,
> > >
> > >  I should have written "without generic operator methods" 
> > -- ES4 could
> > > still have a decimal type and built-in operators and
> > literal support,
> > > but no modal defaulting (no "big red switch").
> > >
> > >  /be
> > >
> > >
> > _______________________________________________
> > Es4-discuss mailing list
> > Es4-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es4-discuss
> > 
> 



More information about the Es4-discuss mailing list