[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [NOISE] Curly braces [was Re: Curl]
Morgan McGuire <morgan3d@yahoo.com> writes:
> That's because you write compilers, not geometry code. The main
> motivation for adding infix to Curl was the graphics guys getting
> killed trying to debug math like:
>
> {if {> {/ {+ {- b} {sqrt {- {* b b} {* 4 a c}}}} {* 2 a} 0}
> 'positive-root
> 'negative-root}
They didn't have an auto-indent editor to work in? That would have
uncovered the missing close brace after {* 2 a} in no time.
Of course, I'm sure the graphics guys would have found the problem in
the following expression at a glance, right?
-b+sqrt(b*b-4*a*c)/2*a > 0 ? "positive-root" : "negative-root"
I do think infix syntax can be helpful, especially once you're used to
the precedence rules. But the problems with prefix syntax are generally
overblown. A little indentation goes a long way.
(if (positive? (/ (+ (- b)
(sqrt (- (* b b)
(* 4 a c))))
(* 2 a)))
'positive-root
'negative-root)
In fact, this example gives division the same kind of prominence it has
as customarily written on paper.
Infix almost always makes it easier to transcribe a math formula into a
computer program, but relative ease of readability/debugging/
understanding is debatable. IMO.
--
<brlewis@[(if (brl-related? message) ; Bruce R. Lewis
"users.sourceforge.net" ; http://brl.sourceforge.net/
"alum.mit.edu")]>