Hacker News new | ask | show | jobs
by r8533292 754 days ago
i'll add to general discussion about syntaxes and infix notation, i'm not sure where to attach this point to existing threads. genera had infix mode, that was enabled on a reader macro. you could write something like

    (defun bresenham (a x0 y0 x1 y1 &aux dx dy d y)
      #◇dx:x1-x0,
        dy:y1-y0,
        d:2*dy-dx,
        y=y0◇
      (loop for x from x0 to x1
            do #◇a[x,y]:1,
                 if d>0 then
                   (y:y+1,
                    d:d-2*dx),
                 d:d+2*dy◇))
you can make the code above fully operational in common lisp using dispatch macro on a unicode character, so i've been experimenting with such infix mode in my private code. i'll leave the judgement over whether or not this increases readibility.