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

Possible enhancement - Macro to remove package boilerplate to function calls? #11

Open
stubillwhite opened this issue Dec 22, 2014 · 3 comments

Comments

@stubillwhite
Copy link

First of all, thank you so much for your work on this -- it's a huge boon and I'm thoroughly enjoying using it in my novice Emacs code.

One possible enhancement that I'd love would be some sort of "import" macro that would enable clients of a particular package to write code without the package prefix boilerplate on all of the functions.

For example, rather than writing:

    (sbw/my-package-function-one "Do something")
    (sbw/my-package-function-two "Do something else")

It would be lovely to be able to do something like:

    (import
      (sbw/my-package- '(function-one function-two))

      (function-one "Do something")
      (function-two "Do something else"))

And have the import macro prepend the my-package- prefix to the named symbols in the body of the macro.

Would something like that be in scope for the project and perhaps useful to others?

@Malabarba
Copy link
Owner

Yes, something like that would definitely be in scope. It's something I've been thinking about a lot, I just haven't got around to it yet.

The way I envisage it would be slightly different. Instead of a new macro, you could have pass a keyword to the define-namespace macro:

(define-namespace this-package-
:import cl-
:import (my-package- function-one function-two)

)

This would import everything that starts with cl-, and would also import function-one and function-two from my-package.

@mwfogleman
Copy link

Artur's version would make :import identical to :use in Clojure. Might be worth borrowing the convention, as it's fewer characters.

http://conj.io/store/org.clojure/clojure/1.6.0/clojure.core/ns/

@Malabarba
Copy link
Owner

@mwfogleman Sure, the simpler the better. I've been thinking of doing something like :require as well.

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

3 participants