[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Always return a list
From: |
Johan Andersson |
Subject: |
Always return a list |
Date: |
Thu, 25 Nov 2010 11:05:17 +0100 |
Hey,
I have a struct. To make it simple, lets assume this is the struct:
(defstruct package name deps)
The deps slot is for the package dependencies. Example of packages:
(make-package :name "one" :deps "two")
(make-package :name "two" :deps '("three" "four"))
To make it easier to use the dependencies from the code, when I call (package-deps package) I always want it to return a list. So:
(let ((one (make-package :name "one" :deps "two"))
(two (make-package :name "two" :deps '("three" "four"))))
(print (package-deps one)) ;; => ("two")
(print (package-deps two)) ;; => ("three" "four")
)
I tried doing this using an advice, with no success:
(defadvice package-deps (around package-deps-around)
(let ((deps ad-do-it))
(if (listp deps) deps (list deps))))
(ad-activate 'package-deps)
Can I do this in a way that doesn't require that much of a hack?
Thanks!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Always return a list,
Johan Andersson <=