"Strong typing vs. strong testing"

Pascal J. Bourguignon pjb at informatimago.com
Fri Oct 1 22:46:59 EDT 2010


"BartC" <bc at freeuk.com> writes:

> "Pascal J. Bourguignon" <pjb at informatimago.com> wrote in message
> news:877hi1iq2o.fsf at kuiper.lan.informatimago.com...
>> "BartC" <bc at freeuk.com> writes:
>
>>> (defun fib (n)
>>>   (if (< n 2)
>>>       n
>>>       (+ n (fib (- n 1)) (fib (- n 2)) )
>>> ))
>>>
>>> But it gave the wrong results and it took ages to figure out why. Even
>
>>> I thought you were saying that Lisp (and dynamic typing in general)
>>> was better for pointing out errors? The above error in C would have
>>> been picked up more easily I think (due to less parentheses clutter,
>>> and more obvious separators between terms).
>>
>> There are more parentheses in C (you must take into account {} and []
>> too, and <> in C++), and the additionnal separators in C are clutter.
>
> I mentioned 'C' because it's one of the cross-posted languages; I normally
> use my own language. Nevertheless, both of these (as well as Python and
> probably many others) require no more than 4 parentheses in the line in
> question; the Lisp line above uses 12
So what?

> (including the 2 I moved to the next
> line for clarity).

Actually for clarity, properly formated lisp code would be like:

(defun fib (n)
  (if (< n 2)
      n
      (+ n
         (fib (- n 1))
         (fib (- n 2)))))


> And needing an extra "+" when you want to add 3 things instead of 2, sort of
> makes it obvious that you do have 3 things instead of 2... In fact the error
> would never have got so far. Sometimes redundancy in syntax is useful.

On the other hand, baroque syntaxes requires more wetware cycles so
you're left with less to think about important matters, such as knowing
what fib is...


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/



More information about the Python-list mailing list