Contents (package MULK.OBJECTIVE-CL)


Function ENABLE-METHOD-SYNTAX

Purpose:

Install a reader macro that makes method calls look nicer.

Syntax:

enable-method-syntax

Description:

The reader macro installed by enable-method-syntax makes it easier to write method invocations as well as making them more readable alongside Lisp code by placing the method name in front. At the same time, it is a more conservative syntax enhancement than that provided by enable-objective-c-syntax.

The reader macro transforms any string of alphanumeric characters and characters that are eql to one of #\:, #\- and #_ into a symbol with that string as the symbol name and objective-c-selectors as the symbol package.

Examples:

#.(enable-method-syntax)  
  
(#/stringWithCString:encoding: (find-objc-class 'ns-string) "Hi there!" 4)  
  => #<NS:GSC-BUFFER-STRING `Hi there!' {821ff58}>  
  
(defvar *lock* (#/new (find-objc-class 'ns-lock)))  
  => *LOCK*  
  
(#/lock *lock*)     => no value  
(#/tryLock *lock*)  => NIL  
(#/unlock *lock*)   => no value  
(#/tryLock *lock*)  => T  
(#/unlock *lock*)   => no value  
  
#.(disable-method-syntax)  
 

Note:

Absent manual interventions by the user, the fdefinition of any fbound symbol read by this reader macro will be a selector.

Method selectors have to be interned prior to use. As this reader macro is not capable of interning new selectors, you have to ensure that intern-selector is called before the respective selector is used. This is not a problem for selectors known at load-time nor for selectors registered by way of collect-methods.

See also:

enable-objective-c-syntax