Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style improvements #1

Open
podiki opened this issue Feb 25, 2017 · 0 comments
Open

Style improvements #1

podiki opened this issue Feb 25, 2017 · 0 comments
Assignees

Comments

@podiki
Copy link
Owner

podiki commented Feb 25, 2017

(via this comment on Reddit):

Mostly looks good, but I've got some style suggestions. Number one, I'd make constructors for your objects instead of inlining make-instance calls. For example:

(defun make-rect (x y w h)
  (let ((r (make-instance 'rect :x1 x :y1 y)))
    (setf (x2 r) (+ (x1 r) width)
          (y2 r) (+ (y1 r) height)
          (center r) (cons (floor (/ (+ (x1 r) (x2 r)) 2)) (floor (/ (+ (y1 r) (y2 r)) 2))))
    rect))

I also rearranged some functions to suggest some style improvements. I'd try to minimize declaring variables just to setf them later... usually you can just add a nested let, or use let*.

@podiki podiki self-assigned this Feb 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant