ruricolist / serapeum

Utilities beyond Alexandria
MIT License
425 stars 42 forks source link

local's def vs. defvar #43

Open Ambrevar opened 5 years ago

Ambrevar commented 5 years ago

The local macro supports defun, etc. but surprisingly it does not support defvar. Instead, the user must use def.

I wonder why that is. Wouldn't that trip the user? Why not supporting defvar for consistency?

ruricolist commented 5 years ago

I wanted to have defvar, but the semantics of a global defvar can't be fully imitated by a local binding. You can make a symbol locally special (using (declare (special ...)), but that binding is only visible in the dynamic environment of called functions if they opt in with a special declaration of their own.

Note that def is supported globally, so it is (at least) consistent.

Ambrevar commented 5 years ago

What about defparameter?

ruricolist commented 5 years ago

Same problem, alas.