Contents (package MULK.OBJECTIVE-CL)


Function FIND-SELECTOR

Purpose:

Retrieve a method selector by name.

Syntax:

find-selector selector-name &optional (errorp t)

Arguments and Values:

selector-name --- a string, a symbol, or a list of symbols.

errorp --- a generalized boolean. The default is true.

Returns: selector --- a selector object, or nil.

Description:

If selector-name is a string, the selector named by that string is returned. If no selector with the given name exists, either nil is returned if errorp is false, or an error of type no-such-selector is signaled if errorp is true.

If selector-name is a symbol, it is treated the same as a list whose only element is the symbol.

If selector-name is a list of symbols, all symbols are first split into parts separated by hyphens and each part converted into a string according to the following rules:

  1. 1. If the keywords' symbol names do contain lowercase characters, their case is left intact.

2. If the keywords' symbol names do not contain any lowercase characters, the following steps are taken in order to adjust their case.

  1. The first part is fully converted to <em>[lowercase](http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lowercase)</em>.  
  
  2. Any additional parts are also fully converted to <em>[lowercase](http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lowercase)</em>  
     except for their first letters, which are left intact. 
  • If the symbol is a keyword, the resulting string is suffixed by a colon (`:').
  • After that, all parts are concatenated in order to form a single selector name component. The selector name components are in turn concatenated in order to form the string that identifies the selector, which is used as if given directly as an argument to a call to find-selector.

    Note that the conversion rules for selector names are identical to those by which invoke converts its arguments into a message name.

    Examples:

    (find-selector "self")       ;=> #<SELECTOR `self'>  
    (find-selector '(self))      ;=> #<SELECTOR `self'>  
    (find-selector 'self)        ;=> #<SELECTOR `self'>  
      
    (find-selector "stringWithCString:encoding:")  
      ;=> #<SELECTOR `stringWithCString:encoding:'>  
      
    (find-selector '(:string-with-c-string :encoding))  
      ;=> #<SELECTOR `stringWithCString:encoding:'>  
      
    #.(setq *readtable* (copy-readtable))  
    #.(setf (readtable-case *readtable*) :invert)  
    (find-selector '(:stringWithCString :encoding))  
      ;=> #<SELECTOR `stringWithCString:encoding:'>  
     
    

    Note:

    Setting the readtable case of the current readtable to :INVERT is a good way of making the Lisp system behave as traditionally as possible while making Objective-C method names case-sensitive.

    On the other hand, writing all method names in lower case while separating parts by hyphens works nicely in all of the :INVERT, :UPCASE, :DOWNCASE, and :PRESERVE modes as well as Allegro CL's modern mode.

    See also:

    intern-selector, selector