Re: Revisiting Decimal (generic algorithms)

2009-01-31 Thread Sam Ruby
Brendan Eich wrote: This variation preserves wrappers, so a Decimal converter function (when invoked) and constructor (via new, and to hold a .prototype home for methods). The committee plunks for more of this primitive/wrapper business, since we have wrappers and primitives for numbers and

Re: Revisiting Decimal (generic algorithms)

2009-01-30 Thread Brendan Eich
On Jan 18, 2009, at 4:48 PM, Brendan Eich wrote: In any case, I think we first need to decide what the semantics would be *after* any desugaring of multimethods. The goal is DWIM, which is why we've circled around these implicit or low-cost-if-explicit approaches. Of course DWIM is

Re: Revisiting Decimal (generic algorithms)

2009-01-30 Thread Brendan Eich
On Jan 30, 2009, at 6:28 PM, Brendan Eich wrote: According to http://en.wikipedia.org/wiki/Polymorphism_(computer_science) (hey, it's referenced): There are two fundamentally different kinds of polymorphism, originally informally described by Christopher Strachey in 1967. If the range of

Re: Revisiting Decimal (generic algorithms)

2009-01-18 Thread Brendan Eich
On Jan 16, 2009, at 7:38 PM, David-Sarah Hopwood wrote: It could be argued that most ES3.x programs are probably not relying on the exact errors introduced by double-precision IEEE 754, but that seems risky to me. Emphatically agreed. People file dups of bug 5856 but they also knowingly and

RE: Revisiting Decimal (generic algorithms)

2009-01-16 Thread Allen Wirfs-Brock
Returning to Brendan's original question... The problem I brought up at the Kona meeting was that the Decimal proposal did not consistently enable the writing of functions that implement generic numeric algorithms. By this I mean algorithms that can be applied to either Number or Decimal

Re: Revisiting Decimal (generic algorithms)

2009-01-16 Thread Brendan Eich
On Jan 16, 2009, at 2:25 PM, Allen Wirfs-Brock wrote: I think that carry dual encodings (both binary and decimal) for each numeric literal might be a reasonable approach as long as we only have two types. Excluding small integer literals, most numeric literals in my experience are small

Re: Revisiting Decimal (generic algorithms)

2009-01-16 Thread David-Sarah Hopwood
Allen Wirfs-Brock wrote: [...] function fuzz(a) { return a + 0.1} //not generic in Kona draft, fuzz(1m) === 1.10008881784197001... (but see below) //Kona spec. uses binary floating point for all mixed mode operations [...] This problem cannot be fixed simply by tweaking the

Re: Revisiting Decimal (generic algorithms)

2009-01-16 Thread David-Sarah Hopwood
David-Sarah Hopwood wrote: Allen Wirfs-Brock wrote: [...] function fuzz(a) { return a + 0.1} //not generic in Kona draft, fuzz(1m) === 1.10008881784197001... (but see below) //Kona spec. uses binary floating point for all mixed mode operations [...] This problem cannot be

Re: Revisiting Decimal (generic algorithms)

2009-01-16 Thread Brendan Eich
On Jan 16, 2009, at 4:30 PM, Sam Ruby wrote: Indeed. This is the first time I understood (at a high level) the request. I'm not saying it wasn't explained before, or even that it wasn't explained well, but this is the first time I understood it (again at a high level, questions on details

Re: Revisiting Decimal (generic algorithms)

2009-01-16 Thread Brendan Eich
On Jan 16, 2009, at 5:30 PM, David-Sarah Hopwood wrote: David-Sarah Hopwood wrote: function id(x) { return x; } What is the result and type of id(0.1) in this approach, and why? - if binary 0.1, then we would have 1m + 0.1 !== 1m + id(0.1) which breaks referential transparency (in

Re: Revisiting Decimal (generic algorithms)

2009-01-16 Thread Sam Ruby
On Fri, Jan 16, 2009 at 8:30 PM, Brendan Eich bren...@mozilla.com wrote: Like Allen says later, most small integers (i.e., the ones that fit exactly in a double precision binary value) can simply be retained as binary64. Or machine ints -- ALU FPU still. Agreed. Those values that could

Re: Revisiting Decimal (generic algorithms)

2009-01-16 Thread Brendan Eich
On Jan 16, 2009, at 5:54 PM, Sam Ruby wrote: http://www.artima.com/weblogs/viewpost.jsp?thread=101605 I must be dense. My previous understanding of multimethods was that it depends on the assumption that the type of each argument can be determined. That article doesn't change that for me.

Re: Revisiting Decimal (generic algorithms)

2009-01-16 Thread David-Sarah Hopwood
Brendan Eich wrote: On Jan 16, 2009, at 5:30 PM, David-Sarah Hopwood wrote: David-Sarah Hopwood wrote: function id(x) { return x; } What is the result and type of id(0.1) in this approach, and why? - if binary 0.1, then we would have 1m + 0.1 !== 1m + id(0.1) which breaks

Re: Revisiting Decimal (generic algorithms)

2009-01-16 Thread Mark S. Miller
On Fri, Jan 16, 2009 at 5:34 PM, Brendan Eich bren...@mozilla.com wrote: Have you looked at multimethods in Cecil? http://www.cs.washington.edu/research/projects/cecil/pubs/cecil-oo-mm.html http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.48.8502 On your recommendation, I have. I