RodrigoZepeda / d3lisp

A d3js interface for creating plots in LISP
https://rodrigozepeda.github.io/d3lisp/index.html
MIT License
3 stars 0 forks source link

Proposal: Idiomatic naming & parentheses #7

Closed Symbolics closed 5 years ago

Symbolics commented 5 years ago

Lisp naming conventions suggest that the - character be used as a word separator, both in function names and keyword arguments. These naming conventions make it easier for experienced lisp coders to work with and make contribution to the code.

So, for example, 'createplot' would be named create-plot and the keyword argument showXaxis would be show-x-axis. Normally there are two ways to do such a conversion:

The former is good when there is a single contributor, where he can update a function the next time it is modified. The latter, all-at-once, is generally better when there is more than one contributor because when reviewing code it is more difficult to separate the change in functionality vs. the change in naming.

With parentheses, there is a good stackoverflow discussion on parentheses that includes references and general preferences for parentheses placement. Mostly this involves collecting all closing parentheses at the end of the last line of code, rather than on an individual line by themselves.

This proposal is to rename functions, variables and keyword arguments, as well as fix the parentheses placement, according to the standard naming conventions, using the all-at-once method.

Symbolics commented 5 years ago

FYI: here is a renamed function signature that I created for the plot wrapper function. It would also work in create-plot.

(defun plot  (x y &key (x-label "My x label") (y-label "My y label") (title "My Title") (size 7)
                    (x-minimum NIL) (y-minimum NIL) (x-maximum NIL) (y-maximum NIL) (scatter-color "green")
                    (line-color "purple") (line-width 3) (stroke-fill "none") (line T) (scatter T)
                    (interpolation "Linear") (show-x-axis T) (show-y-axis T)
                    (x-axis-label-color "black") (y-axis-label-color "black")
                    (x-axis-tick-color "black") (y-axis-tick-color "black") (x-axis-color "black")
                    (y-axis-color "black") (line-opacity 1) (scatter-opacity 1)
                    (y-axis-position NIL) (x-axis-position NIL)
                    (plot-height "default") (plot-width "default")
                    (outer-color "none") (inner-color "none") (annotations NIL)
                    (annotations-color "black") (annotations-fontsize 12)
                    (title-fontsize 18) (title-color "black")
                    (margin (list 10 10 10 10)) (padding (list 30 30 60 60))
                    (square-plot NIL) (save NIL) (svg-name "Myplot")
RodrigoZepeda commented 5 years ago

Thank you so much for your input. I'll be working today on this and then, if possible during the week, on the additional proposals.

RodrigoZepeda commented 5 years ago

I have rewritten most of the code for what I gather is more idiomatic LISP considering Google's guidelines. Also comments were added. Only curves.lisp is missing.

RodrigoZepeda commented 5 years ago

I think I have rewritten all the functions and added function description to each. I am closing this issue now.