{"id":17324436,"url":"https://github.com/guicho271828/aspectm","last_synced_at":"2026-01-06T14:40:32.896Z","repository":{"id":29062439,"uuid":"32590291","full_name":"guicho271828/aspectm","owner":"guicho271828","description":"aspect-oriented hooks","archived":false,"fork":false,"pushed_at":"2017-10-20T03:22:42.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T09:29:52.082Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Common Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guicho271828.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-20T15:04:36.000Z","updated_at":"2020-02-13T13:57:26.000Z","dependencies_parsed_at":"2022-09-06T08:54:14.358Z","dependency_job_id":null,"html_url":"https://github.com/guicho271828/aspectm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guicho271828%2Faspectm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guicho271828%2Faspectm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guicho271828%2Faspectm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guicho271828%2Faspectm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guicho271828","download_url":"https://codeload.github.com/guicho271828/aspectm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245779587,"owners_count":20670701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T14:10:39.505Z","updated_at":"2026-01-06T14:40:32.821Z","avatar_url":"https://github.com/guicho271828.png","language":"Common Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n* Aspectm  - control macroexpand hooks\n\n=*macroexpand-hook*= in Common Lisp is quite hard to maintain correctly,\nsince it is global and anyone can modify its value. This library is an\nexperimental attempt to provide a set of \"acceptable\" way of modifying the\nhook. Well, I feel, kind of defeated.\n\nAspectM provides CLOS-like /around/, /before/, /after/ hooks for\nmacroexpansion, and I planned to implement useful hooks based upon this system.\n\n#+BEGIN_SRC lisp\n(enable-macroexpand-hooks)       ; enable around hooks, then\n(add-around-hook 'standard-hook) ; register standard (=before+after) hook as an around hook\n\n;; expanded before the main expansion, then prepended to the main expansion result\n(defmacro force-inline (\u0026whole form name args \u0026body body)\n  (assert (eq 'defun (car form)))\n  `(declaim (inline ,name)))\n\n(set-standard-hook 'defun 'force-inline :before)\n\n(macroexpand\n  `(defun my-+ (x y) (+ x y)))\n\n(remove-standard-hook 'defun 'force-inline :before)\n;; there are also with-standard-hook\n#+END_SRC\n\n# Note: *ABOVE CODE DOES NOT WORK.*\n\nI want the scope of these hooks to be file local, but not sure how.\nThis is the main reason I stopped the development.\n\n# Sounds simple, but actually not. The main problem is about the invalidation\n# of the compilation results, and the scope of the hook.  What happends if we put a hook\n# =set-standard-hook= in file A, which is loaded before a file B that\n# contains =my-+= above, but the file B is already compiled? What if a user\n# forgot adding =remove-standard-hook= in the end of file B? It affects every\n# single file loaded after it. Well, this might be a matter of ASDF system\n# definition, but there are various similar effects.\n# \n# The scope of a hook is package. Each enable-macroexpand-hooks remembers its \n\n* Details\n\n/around/ hooks are always nested, and I suppose this is the expected usage of\n=*macroexpand-hook*=. Notable difference is that \nevery /around/ hooks MUST call the next hook by calling =(call-next-hook)=,\nor it signals an compile-time error. This ensures that all hooks are called\nin the right order without skipping/overriding.\n\nBased on this system, AspectM implements a set of hooks\ncalled /standard/ hooks, which consist of /before/ and /after/ hooks,\njust like /before/ and /after/ methods in CLOS.\nThe functionalities of before/around hooks follow:\n\n+ It can see the arguments of the macro.\n+ It can prepend/append forms to the main form returned by the macro, each wrapped in progn.\n+ However it cannot modify the main expansion result.\n\nExpected usecases: Side-effects upon expansion. E.g. exporting symbols,\nproclaim =inline=, or storing the form as a workaround for a system that\ndoes not provide =function-lambda-expression=.\n\nUnfortunately, =load= and =compile= does *not* rebind =*macroexpand-hook*=\nas they do for =*readtable*= and =*package*=. You are warned.\n\n* Setting a Standard Hook\n\n/before/ and /after/ hooks are regular macro-functions of two arguments\n(the form and environment). The example code below automatically adds\n=inline= proclaration to all =defun=-ed function.\n\n#+BEGIN_SRC lisp\n\n(defmacro force-inline (\u0026whole form name args \u0026body body)\n  (assert (eq 'defun (car form)))\n  `(declaim (inline ,name)))\n\n(set-standard-hook 'defun 'force-inline :before)\n\n#+END_SRC\n\n* Dependencies\n\nThis library is at least tested on implementation listed below:\n\n+ SBCL 1.2.8 on X86-64 Linux  3.13.0-46-generic (author's environment)\n\nAlso, it depends on the following libraries:\n\n+ alexandria by  ::\n    Alexandria is a collection of portable public domain utilities.\n\n+ lisp-namespace by Masataro Asai ::\n    Provides LISP-N --- extensible namespaces in Common Lisp.\n\n* Copyright\n\nCopyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com)\n\n\n* License\n\nLicensed under the LLGPL License.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguicho271828%2Faspectm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguicho271828%2Faspectm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguicho271828%2Faspectm/lists"}