Paste number 1684: macrolet has both lexical and dynamic scope

Index of paste annotations: 2 | 1

Paste number 1684: macrolet has both lexical and dynamic scope
Pasted by: KONiemitalo
When:15 years, 4 months ago
Share:Tweet this! | http://paste.lisp.org/+1AS
Channel:#emacs
Paste contents:
Raw Source | XML | Display As
(defmacro kon-test-1 ()
  ''lexical)
(defun kon-test-2 ()
  (kon-test-1))
(defalias 'kon-test-3 'kon-test-1)
(macrolet ((kon-test-1 () ''dynamic))
  (list (kon-test-2) (kon-test-3)))
;; => (lexical dynamic)

Annotations for this paste:

Annotation number 2: defvaralias sees the outer definition
Pasted by: KONiemitalo
When:15 years, 4 months ago
Share:Tweet this! | http://paste.lisp.org/+1AS/2
Paste contents:
Raw Source | Display As
;;; GNU Emacs 21.3.50.40 (i386-pc-linux-gnu, GTK+ Version 2.4.2) of 2004-07-09 on Astalo

(defvar kon-test-7 'outer)
(defvaralias 'kon-test-8 'kon-test-7)

(let ((kon-test-7 'inner))
  (list kon-test-7 kon-test-8))
;; => (inner inner)

(lexical-let ((kon-test-7 'inner))
  (list kon-test-7 kon-test-8))
;; => (inner outer)

(symbol-macrolet ((kon-test-7 'inner))
  (list kon-test-7 kon-test-8))
;; => (inner outer)

Annotation number 1: defalias uses the environment of the call with a function too
Pasted by: KONiemitalo
When:15 years, 4 months ago
Share:Tweet this! | http://paste.lisp.org/+1AS/1
Paste contents:
Raw Source | Display As
(defun kon-test-4 ()
  'outer)
(defun kon-test-5 ()
  (kon-test-4))
(defalias 'kon-test-6 'kon-test-4)

(labels ((kon-test-4 () 'inner))
  (list (kon-test-4) (kon-test-5) (kon-test-6)))
;; => (inner outer inner)

(flet ((kon-test-4 () 'inner))
  (list (kon-test-4) (kon-test-5) (kon-test-6)))
;; => (inner inner inner)

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.