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

It looks OK to me:

    (define (time-to-move from-pos to-pos)
      ;; Calculates the total time to move between two positions,
      ;; assuming rotation and ascension can occur simultaneously.
      (max (time-to-rotate (position-azimuth   from-pos)
                           (position-azimuth   to-pos))
           (time-to-ascend (position-elevation from-pos)
                           (position-elevation to-pos))))



Yet the author injects needless complexity with macros and claims "I think it’s possible to write clearer Lisp code, I just don’t know how." I don't get it.


Yeah, I was going to say. The simplicity and readability of Lisp code is inversely proportional to the use of macros.


Let's get rid of macros then


The simplicity and readability of Lisp-- code is now inversely proportional to how useful macros would have been to write it.


In projects? Yes, scaling them back is a good idea. They're a specific tool with a specific use. It's profoundly annoying, especially in Nim world, to pull in a library that then hides all of its functionality in code paths that are only generated at compile time. Things become very difficult to debug.


indeed. Note that's a function declaration in Common Lisp (yours is Scheme):

    (defun time-to-move (from-pos to-pos)
it's like the author didn't understand accessors? They don't need the with-accessors. They also might not need with-slots, had they had an accessor for last-duration.

    (with-slots (last-duration) antenna
      (setf last-duration total-time)
=>

    (setf (last-duration antenna) total-time)  ;; given last-duration is an accessor: both a getter and a setter.


Yeah, the total run-scan function could be fairly short:

  (defun run-scan (antenna scan)
    "Perform a scan on this antenna. Return a scan log."
    (let* ((slew-time (move-to antenna (scan-position scan)))
           (on-source-time (delay antenna (scan-length scan))))
      (setf (antenna-last-duration antenna) (+ on-source-time slew-time))
      (make-scan-log scan slew-time on-source-time)))


(No need for LET*, just LET would suffice.)


LET* may be needed if the operations are time-dependent (so if the move-to operation must happen before the delay operation), as LET does the binding in parallel (at least, according to the spec).


That is a very acute observation!




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: