Plaster
New
List
Login
text
apl
aspx
asterisk
brainfuck
c
c++hdr
c++src
cassandra
ceylon
clojure
clojurescript
cmake
cobol
coffeescript
common-lisp
crystal
csharp
css
cypher-query
cython
d
dart
diff
django
dockerfile
dylan
ebnf
ecl
ecmascript
edn
eiffel
ejs
elm
erb
erlang
ez80
factor
fcl
feature
forth
fortran
fragment
gfm
go
gql
groovy
gss
haml
handlebars-template
haskell
haxe
hive
html
http
httpd-php
httpd-php-open
hxml
ini
java
javascript
json
jsp
jsx
julia
kotlin
latex
less
literate-haskell
lua
mariadb
markdown
mbox
mirc
mscgen
msgenny
mssql
mumps
mysql
n-triples
nesc
nginx-conf
nsis
objectivec
octave
oz
pascal
perl
pgp
pgp-keys
pgp-signature
pgsql
php
pig
plsql
properties
protobuf
puppet
python
q
rpm-changes
rpm-spec
rsrc
ruby
rustsrc
sas
sass
scala
scheme
scss
sieve
slim
smarty
solr
soy
sparql-query
spreadsheet
sql
squirrel
stex
styl
swift
systemverilog
tcl
textile
tiddlywiki
tiki
tlv
tornado
ttcn-asn
ttcn-cfg
turtle
twig
typescript
typescript-jsx
vb
vbscript
velocity
verilog
vertex
vhdl
vue
webidl
xml
xml-dtd
xquery
xu
yaml
z80
default
Visibility:
public
unlisted
private
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Extracted MACROP (defun macrop (form env) (cond ((symbolp form) (let* ((local-match (find form (agnostic-lizard:metaenv-variable-like-entries env) :key #'first)) (local-content (second local-match))) (ecase (first local-content) (:plain nil) ((:macro :macro-from nil) t)) (not (null (member (first local-content) '(:macro :macro-from nil)))))) ((consp form) (let* ((local-match (find (first form) (agnostic-lizard:metaenv-function-like-entries env) :key #'first)) (local-content (second local-match))) (ecase (first local-content) (:plain nil) ((:macro :macro-from :macro-function-code :macro-code) t) ((nil) (cond ;; A lambda expression. ((consp (first form)) nil) ;; Not a macro. ((null (macro-function (first form) (agnostic-lizard::metaenv-fallback-env env))) nil) ;; The fallback is the global environment anyway. ((null (agnostic-lizard::metaenv-fallback-env env)) t) ;; No macro defined or an FLET shadows the macro. ((null (macro-function (first form) (agnostic-lizard::metaenv-fallback-env env))) nil) ;; METAENV does not contain anything meaningful. ((agnostic-lizard::metaenv-irrelevant-for-macroexpand env) t) ;; The macro is from the global environment or defined inside the ;; walked fragment. ((eq (macro-function (first form) nil) (macro-function (first form) (agnostic-lizard::metaenv-fallback-env env))) t) ;; Policy says not to pass the fallback environment. Need to pull ;; the name into the environment used, otherwise the expansion won't ;; happen at all. ((agnostic-lizard::metaenv-never-pass-fallback-env env) t) ;; The macro is from a MACROLET reflected in the fallback ;; environment. Assume MACROEPAND calls inside the macro function ;; expect some other outside MACROLET to be in effect. (t t)))))) (t nil))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; WITH-OVERLOAD-3 ;;; DONE: What about implementing a macro expansion inhibiting code walker by ;;; replacing macro forms with something that is not walked, like QUOTE. The ;;; quoted expression could include the original form and an additional marker ;;; that could be used to later undo the changes. ;;; DONE: Before using MACROP we should check whether the form is a call to a ;;; special or a hardwired operator. This ties into the Agnostic Lizard issue ;;; regarding the relative ordering of checking for macros and checking for ;;; special or hardwired operators within METAENV-MACROEXPAND-ALL. ;;; DONE: We can't do the replacement within :ON-MACROEXPANDED-FORM because by ;;; that point Agnostic Lizard will already have attempted to macro expand the ;;; form. Regardless of discarding the expansions, we don't even want to attempt ;;; macro expansion because it might have side effects. (defun special-or-hardwired-p (form) (and (consp form) (or (special-operator-p (car form)) (and (find (car form) agnostic-lizard::*hardwired-operators*) t)))) (defmacro with-overload-3 (specs &body body &environment env) (let ((marker '#:with-overload-marker)) (agnostic-lizard:walk-form `(progn ,@body) (make-instance 'agnostic-lizard:walker-metaenv :fallback-env env) :on-every-form-pre (lambda (f env) (if (and (consp f) (not (special-or-hardwired-p f)) (macrop f env)) `',(list marker f) f)) :on-special-form (lambda (f env) (declare (ignore env)) (if (and (eq (car f) 'quote) (consp (second f)) (eq (first (second f)) marker)) (second (second f)) f)) :on-function-form (lambda (f env) (declare (ignore env)) (if (consp f) (let ((rep (find (car f) specs :key #'first :test #'string-equal))) (if rep (cons (second rep) (cdr f)) f)) f)))))