Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • cmucl cmucl
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 56
    • Issues 56
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 8
    • Merge requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • cmucl
  • cmuclcmucl
  • Issues
  • #3
Closed
Open
Issue created Apr 23, 2015 by Mark Cox@mcox

Shadowing compiler macro functions.

CMUCL does not shadow the compiler macro function present in the global environment when introducing a function with the same name in the current lexical environment.

This is demonstrated with the following example:

(defun square (x)
  (expt x 2))

(define-compiler-macro square (x)
  `(expt ,x 2))

(defmacro with-square-check (&body body &environment env)
  (let ((text (if (compiler-macro-function 'square env)
                  "Yes"
                  "No")))
    (progn
       (format t "SQUARE compiler macro present: ~A.~%" ,text)
       ,@body)))

(defun test/absent ()
  (with-square-check
    (square 2)))

(defun test/present ()
  (flet ((square (x)
           (print (expt x 2))))
    (with-square-check
      (square 2))))

CL-USER> (test/absent)
SQUARE compiler macro present: Yes.
=> 4

CL-USER> (test/present)
SQUARE compiler macro present: Yes.

4
=> 4

Thanks Mark

Assignee
Assign to
Time tracking