add STYLEGUIDE
A styleguide can be beneficial to… guide new contributors.
There aren't a lot of "don't"s or "must"s.
I gathered remarks that were applied on some pull requests, and you might recognize one or two preferences of mine.
This first attempt is here for debate.
I guess this is a letter for my usual messy changes.
Can we add a section on dynamic binding?
What I'm really asking: can we ban dynamic binding unless it's really necessary?
defvar/defparameter make a lot of sense for, say, defining variables which are to be customized by the user. But actually using dynamic extent to substitute for passing function parameters, a la
(defvar *var* 1)
(defun foo ()
*var*)
(let ((*var* 2))
(foo))
is, IMO, a trap. Sure, you save a function parameter: on the other hand, you torpedo your ability to run code in separate threads.
Obviously, it's not like avoiding dynamic binding will magically make all of our code thread safe, and Lem probably doesn't really use concurrency at the moment. But I think we should plan for the future and learn from Emacs's experience in this regard
I too think you are right to avoid unnecessary dynamic bindings as a good code writing practice.
However, dynamic bindings are thread-safe. https://www.sbcl.org/manual/#Special-Variables
Oh wow, I had no idea that bindings were thread-local. Thanks for clearing that up
@vindarel Is it okay to merge this?
Hi yes it is IMO, I edited it after your remarks.