Previous Section Next Section Table of Contents Glossary Index

Chapter 13. The Foreign-Function Interface

13.9. Reading Foreign Names

CCL provides several reader macros to make it more convenient to handle foreign type, function, variable, and constant names. Each of these reader macros reads symbols preserving the case of the source text, and selects an appropriate package in which to intern the resulting symbol. These reader macros are especially useful when your Lisp code interacts extensively with a foreign library—for example, when using Mac OS X's Cocoa frameworks.

These reader macros include "#_" to read foreign function names, "#&" to read foreign variable names (note that in earlier versions of OpenMCL the reader macro "#?" was used for this same purpose), "#$" to read foreign constant names, "#/" to read the names of foreign Objective-C methods, and "#>" to read keywords that can be used as the names of types, records, and accessors.

All of these reader macros preserve the case of the text that they read; beyond that similarity, each performs some additional work, unique to each reader macro, to create symbols suitable for a particular use. For example, the function, variable, and constant reader macros intern the resulting symbol in the "OS" package of the running platform, but the reader macro for Objective-C method names interns symbols in the "NEXTSTEP-FUNCTIONS" package.

You are likely to see these reader macros used extensively in Lisp code that works with foreign libraries; for example, CCL IDE code, which defines numerous Objective-C classes and methods, uses these reader macros extensively.

For more detailed descriptions of each of these reader macros, see the Foreign-Function-Interface Dictionary section.


Previous Section Next Section Table of Contents Glossary Index