[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: "John.Cowan" <jcowan@xxxxxxxxxxxxxxxxx>*Subject*: Re: meta-comment on typing*From*: Per Bothner <per@xxxxxxxxxxx>*Date*: Tue, 11 Oct 2005 09:55:56 -0700*Cc*: srfi-77@xxxxxxxxxxxxxxxxx*Delivered-to*: srfi-77@xxxxxxxxxxxxxxxxx*In-reply-to*: <20051006190819.GC14092@NYCMJCOWA2>*References*: <20051006190819.GC14092@NYCMJCOWA2>*User-agent*: Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720)

John.Cowan wrote:

For example, if the programmer knows that f is a list of fixnums, there is no way to apply fixnum addition to them, whereas (apply fx+ f) is trivial.

Well. fx+ as currently specified is binary. So (apply fx+ f) is equivalent to: (apply (lambda ((v1 :: <fixnum>) (v2 :: <fixnum>)) (+ v1 v2)) f) For a general-length list one can of course use reduce. Admittedly more tedious.

Similarly, a HOF involving fixnums can't take advantage of fixnum arithmetic: (define (op f (x :: fixnum) (y :: fixnum)) (f x y)) will perform generic addition, not fixnum addition, if called as (op + 2 3).

No, it will perform fixnum arithmetic, but fixnum arithmetic will be selected using a run-time type dispatch. This requires that integers and fixnums are distinguishable at runtime. I.e. (eqv? 10 (as <fixnum> 10)) => #f though: (= 10 (as <fixnum> 10)) => #t just like: (eqv? 10 10.0) =>f and (= 10 10.0) => #t. I have mixed feelings about whether fx+ should be in R6RS. I would like for (fx+ x y) to be equivalent to: (+ (as <fixnum> x) (as <fixnum) y)) That does require that 10 and (as <fixnum> 10) be different. This can be partly hidden from implementations that don't have separate fixnum values, if we define (fixnum? x) as testing whether x is in the fixnum *range* rather than having the fixnum type. What I do need to request is this: (eqv? 5 (fx+ 2 3)) => unspecified -- --Per Bothner per@xxxxxxxxxxx http://per.bothner.com/

**References**:**Re: meta-comment on typing***From:*John.Cowan

- Prev by Date:
**Integers as Bits [was Re: integer-length]** - Next by Date:
**safe/unsafe mode** - Previous by thread:
**Re: meta-comment on typing** - Next by thread:
**minor comments** - Index(es):