Created
March 17, 2015 04:26
-
-
Save mpontus/c0885127b424d2f7f1d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cl-defun test (&key bar) | |
(message "bar: %s" bar)) | |
(test :bar 'qwe) | |
;; "bar: qwe" | |
(cl-defun test (&rest foo &key bar) | |
(message "foo: %s bar: %s" foo bar)) | |
(test 'qwe :bar 'asd) | |
;; (error "Keyword argument qwe not one of (:bar)") | |
(cl-defun test (&rest foo &key bar &allow-other-keys) | |
(message "foo: %s bar: %s" foo bar)) | |
(test 'qwe :bar 'asd) | |
;; "foo: (qwe :bar asd) bar: nil" | |
(cl-defun test (&rest foo &key bar baz) | |
(message "foo: %s bar: %s baz: %s" foo bar baz)) | |
(test 'qwe :bar 'asd :baz 'zxc) | |
;; (error "Keyword argument qwe not one of (:bar :baz)") | |
(cl-defun test (&rest foo &key bar baz &allow-other-keys) | |
(message "foo: %s bar: %s baz: %s" foo bar baz)) | |
(test 'qwe :bar 'asd :baz 'zxc) | |
;; "foo: (qwe :bar asd :baz zxc) bar: nil baz: nil" | |
(test 'asd :bar 'qwe :baz 'zxc) | |
(cl-defun test (arg &rest foo &key bar baz &allow-other-keys) | |
(message "arg: %s foo: %s bar: %s baz: %s" arg foo bar baz)) | |
(test 123 'asd :bar 'qwe :baz 'zxc) | |
;; "arg: 123 foo: (asd :bar qwe :baz zxc) bar: nil baz: nil" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment