<p>Still struggling to understand what best practices are with respect to macros.  I'm attempting to write a macro which defines packages on the fly.</p>

<pre><code>(defmacro def-dynamic-package (name)
  `(defpackage ,(intern (string-upcase name) "KEYWORD")
     (:use :common-lisp)))
</code></pre>

<p>This works fine only for expressions such as:</p>

<pre><code>(def-dynamic-package "helloworld")
</code></pre>

<p>But fails miserably for something like this:</p>

<pre><code>(defun make-package-from-path (path)
  (def-dynamic-package (pathname-name path)))
</code></pre>

<p>or</p>

<pre><code>(defun make-package-from-path (path)
  (let ((filename (pathname-path)))
     (def-dynamic-package filename)))
</code></pre>

<p>I understand how most basic macros work but how to implement this one escapes me.</p>

Failure is to be expected here, because a macro is used when its argument should not be evaluated.
In your first make-package-from-path, the def-dynamic-package will receive as argument a list that is EQUAL to the value of the following expression:
```
```
(list 'pathname-name 'path)
```
```
In your case, you only want a function:
```
```
(defun def-dynamic-package (name)
  (defpackage (string-upcase name)
    (:use :common-lisp)))
```
```
BTW, if you check the
CLHS
, you'll see that the first argument of
defpackage
needn't be a symbol, but any
string designator
.