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

*To*: Alex Shinn <alexshinn@x>*Subject*: Re: [Scheme-reports] Legacy caar to cddddr*From*: Aubrey Jaffer <agj@x>*Date*: Fri, 21 Oct 2011 20:03:12 -0400 (EDT)*Cc*: cowan@x, scheme-reports@x*In-reply-to*: <CAMMPzYObQPQgkxuuO_GgXX8se=8c8arpdBznOaJ+HS1fZNMwhQ@mail.gmail.com> (message from Alex Shinn on Fri, 21 Oct 2011 11:47:58 +0900)*References*: <20111014235009.GE3033@mercury.ccil.org> <qotty79gfmp.fsf@ruuvi.it.helsinki.fi> <CAMMPzYOe7zoQewoVLXrS8D2OKuMOOWkYDMD3NthWU=dMiJhV5Q@mail.gmail.com> <4EA054EA.40303@sonic.net> <20111020174551.GB23162@mercury.ccil.org> <20111020201726.5A4908C0244@voluntocracy.org> <CAMMPzYObQPQgkxuuO_GgXX8se=8c8arpdBznOaJ+HS1fZNMwhQ@mail.gmail.com>

| Date: Fri, 21 Oct 2011 11:47:58 +0900 | From: Alex Shinn <alexshinn@x> | | On Fri, Oct 21, 2011 at 5:17 AM, Aubrey Jaffer <agj@x> wrote: | > | > In JACAL, polynomials are lists (of variable and coefficients) so | > that polynomial operations use the fastest operations that SCM | > (and other Scheme implementations) offers. Changing polynomials | > to boxed record types would have a disastrous impact on memory | > usage, cache locality, and execution speed of JACAL. | | That's fine, that's just using CAR and CDR, and possibly | CAAR and CDAR for the variable and coefficient of the | first term in the polynomial, so we're not even talking | about the three and four level accessors that I'm proposing | removing. | | However, it would be better to abstract this: | | (define (term-variable x) (car x)) | (define (term-coefficient x) (cdr x)) That would run slower in interpreters. We can do better by remembering that Scheme has first-class procedures: (define term-variable car) (define term-coefficient cdr) But those aren't how JACAL uses pairs. It would be something like: (define poly:var car) (define bunch:first car) (define poly:coefficients cdr) (define poly:constant-term cadr) (define poly:linear-coefficient caddr) (define poly:non-constant-coefficients cddr) Notice that we are already into the third level with CADDR. These accessor names do not cover all the ways in C*R they can be used. CAR is also the constant in a coefficient list, or the first coefficient in the CDR of a coefficient list... CONS can be used to attach a variable to a list of coefficients, to raise the variable exponent by 1 on all terms in a coefficient list, to add an element to the front of a "bunch" (which serve as mathematical vectors)... Multiple versions of MAP would be needed. | in one place, which makes it easier to replace with an | alternate representation which could be faster in other | implementations. JACAL extensively uses the properties of pairs in its manipulations, resulting in succinct code. So Scheme pairs are already optimized for JACAL. If you have a data representation with all the properties of pairs which is faster than pairs, then replace pairs with your representation. | Littering the bodies of your polynomial | functions with random calls to CDAR just makes the | code illegible and difficult to work with. I don't find your name in any JACAL correspondence or ChangeLog. Have you actually looked at JACAL source? Its unfair to declare my code illegible without having made a serious examination of it. One can't understand JACAL source without knowing Scheme or Lisp. If you know Scheme or Lisp, then uses of C*R are clear. If not, renaming every C*R won't be much help. | [Note if you've got a slow interpreter with no procedure | inlining but performance still matters, you can always | abstract with macros.] (define term-variable car) (define term-coefficient cdr) _______________________________________________ Scheme-reports mailing list Scheme-reports@x http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

**Follow-Ups**:**Re: [Scheme-reports] Legacy caar to cddddr***From:*Alex Shinn <alexshinn@x>

**References**:**[Scheme-reports] Appeal for review help with R7RS draft 4***From:*John Cowan <cowan@x>

**[Scheme-reports] Legacy caar to cddddr***From:*Jussi Piitulainen <jpiitula@x>

**Re: [Scheme-reports] Legacy caar to cddddr***From:*Alex Shinn <alexshinn@x>

**Re: [Scheme-reports] Legacy caar to cddddr***From:*Ray Dillinger <bear@x>

**Re: [Scheme-reports] Legacy caar to cddddr***From:*John Cowan <cowan@x>

**Re: [Scheme-reports] Legacy caar to cddddr***From:*Aubrey Jaffer <agj@x>

**Re: [Scheme-reports] Legacy caar to cddddr***From:*Alex Shinn <alexshinn@x>

- Prev by Date:
**Re: [Scheme-reports] Legacy caar to cddddr** - Next by Date:
**Re: [Scheme-reports] Legacy caar to cddddr** - Previous by thread:
**Re: [Scheme-reports] Legacy caar to cddddr** - Next by thread:
**Re: [Scheme-reports] Legacy caar to cddddr** - Index(es):