Reputation: 10930
What is the difference between the following?
(require "asdf") ; String.
(require 'asdf) ; Symbol.
(require :asdf) ; Keyword.
Which should I use when requiring modules?
Upvotes: 3
Views: 131
Reputation: 10930
This answer is specific to ASDF.
The recommended way to load ASDF is by using (require "asdf")
(i.e. using a lowercase string). According to the ASDF manual, section 3 ("Loading ASDF"):
The recommended way to load ASDF is via:
(require "asdf")
The footnote says:
NB: all implementations except GNU CLISP also accept
(require "ASDF")
,(require 'asdf)
and(require :asdf)
. For portability’s sake, you should use(require "asdf")
.
Upvotes: 0
Reputation:
The argument of require
is a string designator which is
a designator for a string; that is, an object that denotes a string and that is one of: a character (denoting a singleton string that has the character as its only element), a symbol (denoting the string that is its name), or a string (denoting itself).
So any of the above will work. However, require
is defined to make comparisons between module names using string=
, which means that case matters. So this means that (require 'asdf)
is the same as (require :ASDF)
is the same as (require "ASDF")
but is not the same as (require "asdf")
. (In fact, ASDF adds both "asdf"
and "ASDF"
to *modules*
so both will work.)
Personally, I use keyword symbols, so (require :asdf)
, (provide :spotbat)
, which means *modules*
always ends up with upper-case strings.
I find the decision to use string=
to compare module names a bit annoying, but it is what it is now, and it is also compatible with various other conventions: package names, for instance, are case sensitive. And in theory it would allow, for instance, a case sensitive lowercase-preferred language to exist alongside CL in the same image ((find-package "cl")
could be the package that exported all its symbols).
Upvotes: 7