Duplicated keyword arguments

Джерело:
Common Lisp Tips

Дата публікації:
06/12/2012 22:39

Постійна адреса новини:
http://www.vsinovyny.com/8323834

Duplicated keyword arguments

 

06/12/2012 22:39 // Common Lisp Tips

If a function call has two pairs of keyword arguments with the same keyword, the leftmost argument pair is used. This can be helpful if a list of keyword arguments is received and you want to selectively override some value in that argument list in application. There’s no need to use mutation or produce a fresh variation of the list.

For example:

(defun write-escaped (object &rest args &key &allow-other-keys)
  (apply 'write object :escape t args))

* (write "hello" :escape nil)
hello

* (write-escaped "hello" :escape nil)
"hello"

See 3.4.1.4 for details.

 

» Читати повністю

 

« Наступна новина з архіву
The tree-walkers of CL
  Попередня новина з архіву
The four causes of symbol conflicts
»

 

 
© 2026 www.vsinovyny.com