Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yet, for Python the layout is like above, with indentation being significant:

  for i in range(1, 101):
      if i % 15 == 0:
          print("FizzBuzz")
      elif i % 3 == 0:
          print("Fizz")
      elif i % 5 == 0:
          print("Buzz")
      else:
          print(i)
 
It does not need the {} pairs then. Now, are we lost because the {} pairs are missing?

In Lisp you need to learn to apply the same idea of indentation being significant:

  (loop for i from 1 upto 100 do
     (cond ((zerop (mod i 15))
            (write-line "FizzBuzz"))
           ((zerop (mod i 3))
            (write-line "Fizz"))      
           ((zerop (mod i 5))
            (write-line "Buzz"))
           (t
            (write-line (princ-to-string  i)))))
Just imagine the grouping parentheses are not there.

The disadvantages of Lisps are basically two:

a) there are more parentheses because of the nested lists being used to write code

b) one now needs to understand when (sin a) is actually code and when it is data.

The advantage of Lisp syntax:

a) code is already a simple nested data structure

b) the indentation&layout of code can be (and often is) computed from the data, while usually in Python the lines and indentation are significant



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: