chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] update: complex egg


From: Thomas Chust
Subject: Re: [Chicken-users] update: complex egg
Date: Wed, 13 Oct 2004 18:16:42 +0200
User-agent: Mozilla Thunderbird 0.8 (X11/20040918)

Hello,

TiM wrote:
> greetings programs.
>
> i have a few questions about the complex egg.
>
> first, wouldn't it be slightly more efficient to represent a complex
> number as a length 2 vector?

I don't really know how this is implemented in CHICKEN, but in many Schemes cons-cells are more time efficient than vectors or equally efficient. And of course, the acces procedures take less time to type ;)

>
> secondly, don't we need some sort of type identifier to distinguish a
> complex number from a pair, or a length 2 vector?
>
> i'm thinking of something like ('complex . (a . b)) or ('complex . #(a > b)).

It is not strictly necessary to have such a distinction, although it would be a bit cleaner code. It would probably be possible to make the complex data type a tinyclos class for example or to use a custom record data type, as Felix suggested. The main reason I did it the way it is implemented, is that I wanted a high degree of portability across Scheme (and other Lisp dialects) implementations.

>
> i would dearly like to see chicken have a complete numeric system. is
> it possible that this complex egg could be used to give chicken native
> (perhaps optional?) support for complex numbers?

It would be possible, but for native support of complex numbers I would strongly suggest adding a new primitive data type to CHICKEN and using the C library routines for modification of complex numbers internally, because this would bring a huge performance gain compared to my native Scheme implementation.

> [...]

cu,
Thomas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]