Node: Keywords, Next: , Previous: Input and Output, Up: Standard Procedures



Keywords

Keywords are symbolic constants which evaluate to themselves. A keyword is a symbol whose first (or last) character is a colon (":").

keyword obj STKLOS Procedure
Returns #t if obj is a keyword, otherwise returns #f.
          (keyword? 'foo)     => #f
          (keyword? ':foo)    => #t
          (keyword? 'foo:)    => #t
          (keyword? :foo)     => #t
          (keyword? foo:)     => #t
          

make-keyword s STKLOS Procedure
Builds a keyword from the given s. The parameter s must be a symbol or a string.
          (make-keyword "test")    => :test
          (make-keyword 'test)     => :test
          (make-keyword ":hello")  => ::hello
          

keyword->string key STKLOS Procedure
Returns the name of key as a string. The result does not contain a colon.

key-get list key STKLOS Procedure
key-get list key default STKLOS Procedure
List must be a list of keywords and their respective values. key-get scans the list and returns the value associated with the given key. If key does not appear in an odd position in list, the specified default is returned, or an error is raised if no default was specified.
          (key-get '(:one 1 :two 2) :one)     => 1
          (key-get '(:one 1 :two 2) :four #f) => #f
          (key-get '(:one 1 :two 2) :four)    => error
          

key-set! list key value STKLOS Procedure
List must be a list of keywords and their respective values. key-set! sets the value associated to key in the keyword list. If the key is already present in list, the keyword list is physically changed.
          (let ((l '(:one 1 :two 2)))
            (set! l (key-set! l :three 3))
            (cons (key-get l :one)
                  (key-get l :three))            => (1 . 3)
          

key-delete! list key STKLOS Procedure
List must be a list of keywords and their respective values. key-delete remove the key and its associated value of the keyword list. The key can be absent of the list.

key-delete! does the same job than key-delete by physically modifying its list argument.

          (key-delete '(:one 1 :two 2) :one)    => (:one 1)
          (key-delete '(:one 1 :two 2) :three)  => (:one 1 :two 2)