parenscript does not redefine "defun", it imports cl:defun and exports it again.
CL-USER> (eq 'ps:defun 'cl:defun )
T
Exporting has nothing to do with the package lock. it refers to when you try to redefine cl:defun.
You can define your own defun in your own package. The library Series does this but it does not export it.
from s-package.lisp
(defpackage #:series
(:use #:cl)
(:export
...
)
(:shadow
#:let #:let* #:multiple-value-bind #:funcall #:defun
#+(or cmu scl) #:collect #+(or cmu scl) #:iterate)
....
)
from s-code.lisp:
;; EXTENSION
(defmacro defun (name lambda-list &environment *env* &body body)
(if (dolist (form body)
(cond ((and (stringp form) (eq form (car body))))
((and (consp form) (eq-car form 'declare))
(if (assoc 'optimizable-series-function (cdr form)) (return t)))
(t (return nil))))
(define-optimizable-series-fn name lambda-list body)
(progn (undefine-optimizable-series-fn name)
`(cl:defun ,name ,lambda-list
. ,body))))
you could export it, put it would generate conflicts when you use it.
SERIES> (export 'defun)
T
SERIES> (in-package :cl-user)
#<PACKAGE "COMMON-LISP-USER">
CL-USER> (use-package :series)
USE-PACKAGE #<PACKAGE "SERIES"> causes name-conflicts in
#<PACKAGE "COMMON-LISP-USER"> between the following symbols:
SERIES:DEFUN, COMMON-LISP:DEFUN
[Condition of type NAME-CONFLICT]
See also:
Common Lisp Hyperspec, 11.1.1.2.5 [:section]
; Evaluation aborted on #<NAME-CONFLICT {1002576393}>.
CL-USER>
I hope this clarifies it for you.