Re: [Scheme-reports] Proposal for New Complex Number Syntax Jussi Piitulainen (26 Mar 2012 06:52 UTC)
Re: [Scheme-reports] Proposal for New Complex Number Syntax Jussi Piitulainen (26 Mar 2012 16:26 UTC)
Re: [Scheme-reports] Proposal for New Complex Number Syntax Andrew Robbins (26 Mar 2012 14:29 UTC)
Re: [Scheme-reports] Proposal for New Complex Number Syntax Stefan Edwards (26 Mar 2012 14:51 UTC)
Re: [Scheme-reports] Proposal for New Complex Number Syntax Andrew Robbins (26 Mar 2012 15:03 UTC)
Re: [Scheme-reports] Proposal for New Complex Number Syntax Stefan Edwards (26 Mar 2012 21:25 UTC)
Re: [Scheme-reports] Proposal for New Complex Number Syntax Andrew Robbins (27 Mar 2012 15:44 UTC)
Re: [Scheme-reports] Proposal for New Complex Number Syntax Stefan Edwards (27 Mar 2012 15:50 UTC)
Re: [Scheme-reports] Proposal for New Complex Number Syntax quad (26 Mar 2012 16:16 UTC)

Re: [Scheme-reports] Proposal for New Complex Number Syntax quad 26 Mar 2012 16:15 UTC

On Mon, Mar 26, 2012 at 8:29 AM, Andrew Robbins <andjrob@gmail.com> wrote:
> Why stop there? Why remove only complex notation, when you can get rid
> of nasty rational notation too!

Good question. If I had my way, I would remove the rational notation
too, but I'll keep one target on lock at a time.

Firstly, complex number notation is much more sophisticated than
rational number notation. Just look at the rules for each.

Secondly, the "+" in the complex number notation is supposed to
emulate the mathematical notation "a+bi". Having taught Scheme, some
students wonder why they can't do "5i+3". "+" is of course a
commutative operation, and so this kind of confusion arises. The same
doesn't happen with "/". Some also wonder why "4+3" doesn't work,
especially since it's a valid identifier.

Lastly, there's a good reason to have this #c(a b) syntax that is a
little deeper than a convenient lexical change.

Consider constructing a macro which will generate code for a
fixed-length power-of-2 FFT. When computing an FFT of size N, you're
going to need the primitive N-th roots of unity. For less math savvy
people, you're going to need *constant* complex numbers which apply in
the algorithm.

Now, obviously, you can use MAKE-COMPLEX, but this does not give any
guarantee that the constants are going to be folded. In fact, if
you're generating code in a LAMBDA, then there is a much less chance
of this happening, since LAMBDA is a way to delay computations.

It would be much easier if the notation for complex numbers (and
therefore rationals) welcomed easy construction of literals.

-Robert Smith

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports