Howdy Attila and Co,
I have been desirous of a package like this for quite a while and finally got around to trying out cl-syntax-sugar. I like it very much, so thank you for all your hard work on this front. My primary reason for using this package was to get cl-interpol syntax to be always available when I compile or load either through swank or asdf, and was very happy to see that you had tackled this. I also wanted the clsql reader syntax to behave in a more standard way and to also be attachable to the package we are compiling in. I did not however, want to compile all the available syntaxes that you have created. To this end I restructured the asd files for this project as described below. I wanted to make this patch available to others in case they found it useful, as well as get your opinion on this restructuring. I was unable to get all the tests to pass, but the same number of tests fail before and after my changes (so I am pretty confident I didn't cause them).
* slim-cl-syntax-sugar loads all the necessary pieces to create a syntax and have that work with asdf (and swank if it is loaded) * every syntax is now its own system which relies on slim * the main cl-syntax-sugar asd now just depends on each of the syntax systems and slim * created new clsql-syntax and cl-interpol-syntax packages/systems that rely on the appropriate dependencies and declare defsyntax for their respective syntaxes
Now I can just load the specific syntax I wish to use in my project (eg: :depends-on (:cl-interpol-syntax)) and asdf takes care of loading what is necessary.
Hope this helps someone, Russ Tyndall
New patches:
[added a slim-cl-syntax-sugar asd that is useful for loading only the system with none of its syntaxes Russ Tyndall russ@acceleration.net**20090122214453] { addfile ./slim-cl-syntax-sugar.asd hunk ./slim-cl-syntax-sugar.asd 1 +;;; -*- mode: Lisp; Syntax: Common-Lisp; -*- +;;; +;;; Copyright (c) 2008 by the authors. +;;; +;;; See LICENCE for details. + +(cl:in-package :cl-user) + +;;; try to load asdf-system-connections +(eval-when (:compile-toplevel :load-toplevel :execute) + (flet ((try (system) + (unless (asdf:find-system system nil) + (warn "Trying to install required dependency: ~S" system) + (when (find-package :asdf-install) + (funcall (read-from-string "asdf-install:install") system)) + (unless (asdf:find-system system nil) + (error "The ~A system requires ~A." (or *compile-file-pathname* *load-pathname*) system))) + (asdf:operate 'asdf:load-op system))) + (try :asdf-system-connections))) + +(defpackage #:cl-syntax-sugar-system + (:use :cl :asdf)) + +(in-package #:cl-syntax-sugar-system) + +(defsystem :slim-cl-syntax-sugar + :author ("Levente Mészáros levente.meszaros@gmail.com" + "Attila Lendvai attila.lendvai@gmail.com") + :licence "BSD / Public Domain" + :description "A slim version of syntax sugar without any syntax's defined" + :depends-on (:alexandria :metabang-bind) + :components + ((:module "src" + :components ((:file "package") + (:file "duplicates" :depends-on ("package")) + (:file "asdf-integration" :depends-on ("package" "duplicates")) + (:file "syntax-sugar" :depends-on ("duplicates"))) + ))) + +(defsystem-connection slim-cl-syntax-sugar-and-swank + :requires (:slim-cl-syntax-sugar :swank) + :components + ((:module "src" + :components ((:file "swank-integration"))))) + +(defsystem :lambda-with-bang-args-syntax + :author ("Levente Mészáros levente.meszaros@gmail.com" + "Attila Lendvai attila.lendvai@gmail.com") + :licence "BSD / Public Domain" + :description "the lambda syntax that is packaged by default with cl-syntax-sugar" + :depends-on (:slim-cl-syntax-sugar) + :components + ((:module "src" + :components ((:file "lambda")) + ))) }
[added interpol syntax asd and clsql-syntax.asd Russ Tyndall russ@acceleration.net**20090122215100] { addfile ./cl-interpol-syntax.asd hunk ./cl-interpol-syntax.asd 1 +;; -*- lisp -*- + +(eval-when (:compile-toplevel :load-toplevel :execute) + (unless (find-package :cl-interpol-syntax) + (defpackage :cl-interpol-syntax + (:use :common-lisp :asdf)))) + +(in-package :cl-interpol-syntax) + +(defsystem :cl-interpol-syntax + :description "A cl-syntax-sugar:defsyntax" + :author "Acceleration.net" + :licence "BSD like (so what you want)" + :depends-on (:cl-interpol :slim-cl-syntax-sugar)) + +(defmethod asdf::traverse ( (op asdf:operation) (s (eql (find-system :cl-interpol-syntax)))) + ;; ensure that operations on the system get performed on the system + (let ((results (call-next-method))) + (if (find s results :key #'cdr) + results + (append results (list (cons op s)))))) + +(defmethod asdf:perform ( (op asdf:operation) (system (eql (find-system :cl-interpol-syntax)))) + (when (next-method-p) (call-next-method)) + (let ((*package* (find-package :cl-interpol-syntax))) + (cl-syntax-sugar:define-syntax cl-interpol (&optional (dispatch-char ##) (sub-char #?)) + "define the interpol syntax" + (set-dispatch-macro-character dispatch-char sub-char #'cl-interpol::interpol-reader)))) addfile ./clsql-syntax.asd hunk ./clsql-syntax.asd 1 +;; -*- lisp -*- + +(eval-when (:compile-toplevel :load-toplevel :execute) + (unless (find-package :clsql-syntax) + (defpackage :clsql-syntax + (:use :common-lisp :asdf)))) + +(in-package :clsql-syntax) + +(defsystem :clsql-syntax + :description "A cl-syntax-sugar:defsyntax" + :author "Acceleration.net" + :licence "BSD like (so what you want)" + :depends-on (:clsql :slim-cl-syntax-sugar)) + +(defmethod asdf::traverse ( (op asdf:operation) (s (eql (find-system :clsql-syntax)))) + ;; ensure that operations on the system get performed on the system + (let ((results (call-next-method))) + (if (find s results :key #'cdr) + results + (append results (list (cons op s))) + ))) + +(defmethod asdf:perform ( (op asdf:operation) (system (eql (find-system :clsql-syntax)))) + (when (next-method-p) (call-next-method)) + (let ((*package* (find-package :clsql-syntax))) + (cl-syntax-sugar:define-syntax clsql () + "define the interpol syntax" + (set-macro-character clsql-sys::*sql-macro-open-char* #'clsql-sys::sql-reader-open) + (set-macro-character clsql-sys::*sql-macro-close-char* (get-macro-character #)))))) }
[Transformed the asd files to reference the specific syntax asds when loading Russ Tyndall russ@acceleration.net**20090122225955] { hunk ./cl-interpol-syntax.asd 2 +;; +;; This system is used for defining the cl-interpol syntax +;; hunk ./cl-syntax-sugar.asd 31 - :depends-on (:alexandria :metabang-bind) - :components - ((:module "src" - :components ((:file "package") - (:file "duplicates" :depends-on ("package")) - (:file "asdf-integration" :depends-on ("package" "duplicates")) - (:file "syntax-sugar" :depends-on ("duplicates")) - (:file "one-liners" :depends-on ("duplicates" "syntax-sugar")) - (:file "readtime-wrapper" :depends-on ("one-liners" "duplicates" "syntax-sugar")) - (:file "quasi-quote" :depends-on ("one-liners" "duplicates" "syntax-sugar")) - (:file "feature-cond" :depends-on ("one-liners" "duplicates" "syntax-sugar")) - (:file "string-quote" :depends-on ("one-liners" "duplicates" "syntax-sugar")))))) + :depends-on (:quasi-quote-syntax + :readtime-wrapper-syntax + :string-quote-syntax + :feature-cond-syntax + ;; we want to load this first so put it last in the list + :slim-cl-syntax-sugar + )) hunk ./cl-syntax-sugar.asd 53 - :components - ((:module "src" - :components ((:file "cl-walker-integration") - (:file "lambda" :depends-on ("cl-walker-integration")))))) + :depends-on (:lambda-with-bang-args-syntax)) hunk ./clsql-syntax.asd 2 - +;; +;; This system is used for defining the clsql syntax +;; hunk ./slim-cl-syntax-sugar.asd 51 + :depends-on (:slim-cl-syntax-sugar :cl-walker) + :components + ((:module "src" + :components ((:file "cl-walker-integration") + (:file "lambda" :depends-on ("cl-walker-integration"))) + ))) + +(defsystem :quasi-quote-syntax + :author ("Levente Mészáros levente.meszaros@gmail.com" + "Attila Lendvai attila.lendvai@gmail.com") + :licence "BSD / Public Domain" + :description "the quasi-quote-syntax that is packaged by default with cl-syntax-sugar" + :depends-on (:slim-cl-syntax-sugar) + :components + ((:module "src" + :components ((:file "one-liners") + (:file "quasi-quote" :depends-on ("one-liners")))))) + +(defsystem :readtime-wrapper-syntax + :author ("Levente Mészáros levente.meszaros@gmail.com" + "Attila Lendvai attila.lendvai@gmail.com") + :licence "BSD / Public Domain" + :description "the readtime-wrapper-syntax that is packaged by default with cl-syntax-sugar" hunk ./slim-cl-syntax-sugar.asd 77 - :components ((:file "lambda")) + :components ((:file "one-liners") + (:file "readtime-wrapper" :depends-on ("one-liners"))) hunk ./slim-cl-syntax-sugar.asd 81 +(defsystem :string-quote-syntax + :author ("Levente Mészáros levente.meszaros@gmail.com" + "Attila Lendvai attila.lendvai@gmail.com") + :licence "BSD / Public Domain" + :description "the string-quote-syntax that is packaged by default with cl-syntax-sugar" + :depends-on (:slim-cl-syntax-sugar) + :components + ((:module "src" + :components ((:file "one-liners") + (:file "string-quote" :depends-on ("one-liners")))))) + +(defsystem :feature-cond-syntax + :author ("Levente Mészáros levente.meszaros@gmail.com" + "Attila Lendvai attila.lendvai@gmail.com") + :licence "BSD / Public Domain" + :description "the feature-cond-syntax that is packaged by default with cl-syntax-sugar" + :depends-on (:slim-cl-syntax-sugar) + :components + ((:module "src" + :components ((:file "one-liners") + (:file "feature-cond" :depends-on ("one-liners")))))) + }
Context:
[follow cl-walker walk-ast rename attila.lendvai@gmail.com**20081230135656 Ignore-this: e3f04766224260764759543ab206b5df ] [fix qq reader thinko attila.lendvai@gmail.com**20081229222531 Ignore-this: d2a54b3ab738bda5bcb17db8eb45ae6e ] [fix nested qq reader bug and add log statements. the interesting change is small, getting the previous unquote reader in read-quasi-quote, the rest is logging and indenting attila.lendvai@gmail.com**20081226180008 Ignore-this: 6fb58dad7a72583aa0171a3c31def381 ] [added :unquote-readtable-case to the qq syntax attila.lendvai@gmail.com**20081214154547 Ignore-this: 9a22ab89a7c9f9ce1e85a8d3f5657dc9 ] [TAG 2008-11-27 attila.lendvai@gmail.com**20081127150509 Ignore-this: 130c861e19237f1634b690048054d730 ] Patch bundle hash: 7e8dea941d1e7cd9d379ca7659e6d6eb44e0e6d0