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

Re: [Scheme-reports] Legacy caar to cddddr

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

However, it would be better to abstract this:

  (define (term-variable x) (car x))
  (define (term-coefficient x) (cdr x))

in one place, which makes it easier to replace with an
alternate representation which could be faster in other
implementations.  Littering the bodies of your polynomial
functions with random calls to CDAR just makes the
code illegible and difficult to work with.

[Note if you've got a slow interpreter with no procedure
inlining but performance still matters, you can always
abstract with macros.]


Scheme-reports mailing list