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

Refactor Definition of RPC Commands #52

Open
ejmr opened this issue Aug 22, 2018 · 3 comments
Open

Refactor Definition of RPC Commands #52

ejmr opened this issue Aug 22, 2018 · 3 comments

Comments

@ejmr
Copy link

ejmr commented Aug 22, 2018

See the code in the refactor-rpc-functions branch for all of the details. The code is not finished. But while looking at the project it struck me as a potentially useful refactoring. Please do not merge it because it needs more testing, and discussion, as not everyone may agree it's a worthwhile change.

@ejmr
Copy link
Author

ejmr commented Aug 22, 2018

I should have included a link to the commit in question: bc42e63, to give an idea of my thought process.

@kermorgant
Copy link
Contributor

kermorgant commented Aug 23, 2018

I've never used defmacro before, and have no strong opinion about this change as I'm still a elisp beginner. Just a few questions, mainly out of curiosity

  • How does that affect debugging : are the macro defined functions as easily debuggable ?
  • The replaced functions had autoloading enabled. How does that change affect that ? Should that be a concern ?

I'll try to test this branch in the coming days so I'll probably find out the answer to the first question by myself then ;-)

@ejmr
Copy link
Author

ejmr commented Aug 23, 2018

Are the macro defined functions as easily debuggable?

No. But that doesn't mean they are difficult to debug either. Personally the way I debug anything dealing with macros is by using (macroexpand ...), which lets you see exactly what code a macro expands into. It lets me verify that the macro is creating the code I expect. However it must be said that if developers run into a problem with such a function, GNU Emacs won't point them towards the macro, because for intents and purposes the macro no longer "exists" when the code is compiled.

The replaced functions had autoloading enabled. How does that change affect that?

The dolist form that invokes the macro is marked with the ;;;###autoload directive, so it should apply to every function create by the macro in that dolist construct.

But again, this is all just the result of some brainstorming. Whenever I see a bunch of nearly-identical functions in code, especially in a Lisp with powerful macros, it sets off an alarm in my head reminding me that functional programming and macros provide a way to remove that duplication and (almost) always in a way that decreases bugs and improves how easy it is to add new functionality in the future.i

Edit: If all the code accomplishes is serving as a learning exercise, then I'll be satisfied with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants