• Top
    • Documentation
      • Xdoc
        • Undocumented
        • Save
        • Defsection
          • Throw-away-keyword-parts
          • Extract-keyword-from-args
          • Markup
          • Preprocessor
          • Emacs-links
          • Defxdoc
          • Katex-integration
          • Constructors
          • Entities
          • Save-rendered
          • Add-resource-directory
          • Defxdoc+
          • Testing
          • Order-subtopics
          • Missing-parents
          • Save-rendered-event
          • Archive-matching-topics
          • Archive-xdoc
          • Xdoc-extend
          • Set-default-parents
          • Defpointer
          • Defxdoc-raw
          • Xdoc-tests
          • Xdoc-prepend
          • Defsection-progn
          • Gen-xdoc-for-file
        • ACL2-doc
        • Pointers
        • Doc
        • Documentation-copyright
        • Args
        • ACL2-doc-summary
        • Finding-documentation
        • Broken-link
      • Books
      • Recursion-and-induction
      • Boolean-reasoning
      • Debugging
      • Projects
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Defsection

    Extract-keyword-from-args

    Get the value for a keyword argument like :foo value.

    (extract-keyword-from-args kwd args) is given kwd, which should be a keyword symbol, and a list of args which are typically the &rest args given to a macro. It scans the list of args, looking for the indicated keyword, and returns (kwd . value), or nil if no such keyword is found. For instance,

    (extract-keyword-from-args :bar '(:foo 3 :bar 5 :baz 7))
      -->
    (:bar . 5)

    This function is mainly useful for writing macros that mix &rest parts with keyword arguments. See also throw-away-keyword-parts.

    Function: extract-keyword-from-args

    (defun extract-keyword-from-args (kwd args)
           (declare (xargs :guard (keywordp kwd)))
           (cond ((atom args) nil)
                 ((eq (car args) kwd)
                  (if (consp (cdr args))
                      (cons (car args) (cadr args))
                      (er hard? 'extract-keyword-from-args
                          "Expected something to follow ~s0."
                          kwd)))
                 (t (extract-keyword-from-args kwd (cdr args)))))