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

Complex/Imaginary numbers



Okay, so I want to add an <imaginary> type which can use <complex>
operations (e.g. \+, \*, etc), and is created thusly:

5i; 2 + 7i; 3.14i; sqrt(-12);
5 * i; (2 + 2.2i) / 3; (1.2 - 4.2i) * (0.5 + 6i);

How do I get Dylan to accept i as a postfix numeric modifier to create
an <imaginary> instance.  I really don't want use operations such as
make(<complex>, imaginary: 5) or i(5) to create 5i, nor
make(<complex>, real: 4, imaginary: 3) or 4 + i(3) to create 4 + 3i.

As a side node, I've got the above implemented as pairs (so, 2 + 2.2i
is #(2 . 2.2), and I've added arithmetic operations for pairs to the
generic functions).

Does the macro system have facilities for postfix modifiers?  How have
others done this?

Sincerely, Douglas M. Auclair


Sent via Deja.com http://www.deja.com/
Before you buy.



Follow-Ups: