Pragmatic directives: Difference between revisions

Content added Content deleted
m (promoted to task)
(→‎{{header|D}}: Directives in Common Lisp)
Line 53: Line 53:
'''
'''
'''
'''

=={{header|Common Lisp}}==

Common Lisp usually works with a runtime system which contains an incremental compiler and a file compiler. Various ways are possible to influence the runtime system and the compiler.

=== Declarations ===

* a data allocation can be declared to be done on the stack (if the compiler supports that)
* the optimization settings for the compiler can be set for these qualities: debug, safety, space, speed, compilation speed
* functions can be declared for inline compilation (if the compiler supports that)

=== Feature Expressions ===

Common Lisp provides a way for conditional reading or ignoring of expressions. A variable called lists the available features of an implementation.

Clozure Common Lisp:
? *features*
(:EASYGUI :ASDF2 :ASDF :HEMLOCK :APPLE-OBJC-2.0 :APPLE-OBJC :PRIMARY-CLASSES :COMMON-LISP :OPENMCL :CCL :CCL-1.2 :CCL-1.3 :CCL-1.4 :CCL-1.5 :CCL-1.6 :CCL-1.7 :CCL-1.8 :CLOZURE :CLOZURE-COMMON-LISP :ANSI-CL :UNIX :OPENMCL-UNICODE-STRINGS :OPENMCL-NATIVE-THREADS :OPENMCL-PARTIAL-MOP :MCL-COMMON-MOP-SUBSET :OPENMCL-MOP-2 :OPENMCL-PRIVATE-HASH-TABLES :X86-64 :X86_64 :X86-TARGET :X86-HOST :X8664-TARGET :X8664-HOST :DARWIN-HOST :DARWIN-TARGET :DARWINX86-TARGET :DARWINX8664-TARGET :DARWINX8664-HOST :64-BIT-TARGET :64-BIT-HOST :DARWIN :LITTLE-ENDIAN-TARGET :LITTLE-ENDIAN-HOST)

These features can then use to conditionally execute code:

#+UNIX(print "this is a unix system")

Above would execute the print statement only if the Lisp system has a feature called UNIX.

#-COCOA(require "cocoa")

Above would check for the COCOA feature and if not present, load the library. The library is also expected to later push the feature COCOA to the features list. Reading this code then later would ignore the require statement.


=={{header|D}}==
=={{header|D}}==