All Manuals > LispWorks® User Guide and Reference Manual > 33 The COMMON-LISP Package

*features* Variable

Summary

The features list.

Package

common-lisp

Initial Value

A list containing :lispworks. The actual value varies depending on the platform.

Description

The variable *features* contains a list of feature names.

The following features can be used to distinguish between platforms, or characteristics of the platform or of the LispWorks implementation.

:solaris2
Solaris2
:svr4
System 5 Release 4 machine (for example Solaris2).
:linux
Linux.
:freebsd
FreeBSD.
:darwin
The variant of FreeBSD underlying macOS.
:unix
Unix, including all of the above.
:mswindows
Microsoft Windows, including 32-bit and 64-bit.
:lispworks-64bit
64-bit LispWorks.
:lispworks-32bit
32-bit LispWorks.
:x86

All images that run on the x86 architecture have this feature. This includes the 32-bit implementations on FreeBSD, x86/x86_x64 Linux, x86/x64 Solaris and Windows.

Note: 64-bit LispWorks does not have this feature.

:amd64, :x86-64, :x64

Images that run on the amd64/x86_64/x64 architecture have each of these features. This includes Intel Macintosh, x86_x64 Linux (64-bit), FreeBSD (64-bit), x86/x64 Solaris (64-bit) and Windows (64-bit).

:arm
Images that run on 32-bit ARM architecture.
:arm64
Images that run on 64-bit ARM architecture, including Apple silicon Macs.
:android-delivery

Images generating Android runtimes.

:ios-delivery

Images generating iOS runtimes.

:little-endian
The compiler targets a little-endian machine, for instance x86.
:package-local-nicknames

Support for package-local nicknames (see add-package-local-nickname).

The following features are present in LispWorks with the meanings defined for ANSI CL:

:ansi-cl
:common-lisp
:ieee-floating-point

Conditionalization for the LispWorks implementations

Code can distinguish the current LispWorks implementations like this:

#+(and :mswindows :x86)
"LispWorks (32-bit) for Windows"
#+(and :mswindows :x86-64)
"LispWorks (64-bit) for Windows"
#+(and :linux :x86
       (not :android-delivery))
"LispWorks (32-bit) for x86/x86_64 Linux"
#+(and :linux :x86-64
       (not :android-delivery))
"LispWorks (64-bit) for x86_64 Linux"
#+(and :linux :arm
       (not :android-delivery)
       (not :ios-delivery))
"LispWorks (32-bit) for ARM Linux"
#+(and :linux :arm64
       (not :android-delivery)
       (not :ios-delivery))
"LispWorks (64-bit) for ARM Linux"
#+(and :freebsd :x86)
"LispWorks (32-bit) for FreeBSD"
#+(and :freebsd :x86-64)
"LispWorks (64-bit) for FreeBSD"
#+(and :darwin :x86-64 (not :ios-delivery))
"LispWorks (64-bit) for Intel Macintosh"
#+(and :darwin :arm64 (not :ios-delivery))
"LispWorks (64-bit) for Apple silicon Macintosh"
#+(and :solaris2 :x86)
"LispWorks (32-bit) for x86/x64 Solaris"
#+(and :solaris2 :x86-64)
"LispWorks (64-bit) for x86/x64 Solaris"
#+(and :android-delivery :x86)
"LispWorks (32-bit) for Android Runtime for x86"
#+(and :android-delivery :x86-64)
"LispWorks (64-bit) for Android Runtime for x86_64"
#+(and :android-delivery :arm)
"LispWorks (32-bit) for Android Runtime for arm"
#+(and :android-delivery :arm64)
"LispWorks (64-bit) for Android Runtime"
#+(and :ios-delivery :x86-64)
"LispWorks (64-bit) for iOS Runtime simulator on Intel"
#+(and :ios-delivery :arm64)
"LispWorks (64-bit) for iOS Runtime or Runtime simulator on Apple silicon"

Conditionalization for LispWorks versions

The following features can be used to distinguish between versions of LispWorks:

:lispworks4
All major version 4 releases.
:lispworks4.4
Release 4.4.x
:lispworks5
All major version 5 releases.
:lispworks5.0
Release 5.0.x
:lispworks5.1
Release 5.1.x
:lispworks6
All major version 6 releases.
:lispworks6.0
Release 6.0.x
:lispworks6.1
Release 6.1.x
:lispworks7
All major version 7 releases.
:lispworks7.0
Release 7.0.x
:lispworks7.1
Release 7.1.x
:lispworks8
All major version 8 releases.
:lispworks8.0
Release 8.0.x

Code using new LispWorks functionality should be conditionalized only using features representing earlier versions, so as to future-proof your code:

(defvar *feature-added-in-LispWorks-8.0*
  #+(or lispworks4 lispworks5 lispworks6 lispworks7) nil
  #-(or lispworks4 lispworks5 lispworks6 lispworks7) t)

This is because a feature added in LispWorks 8.0 will generally also be in LispWorks 8.1, LispWorks 9.0 and all later versions.

Similarly:

(defvar *feature-added-in-LispWorks-7.1*
  #+(or lispworks4 lispworks5 lispworks6 lispworks7.0) nil
  #-(or lispworks4 lispworks5 lispworks6 lispworks7.0) t)

or:

(defvar *feature-added-in-LispWorks-7.0*
  #+(or lispworks4 lispworks5 lispworks6) nil
  #-(or lispworks4 lispworks5 lispworks6) t)

or:

(defvar *feature-added-in-LispWorks-6.1*
  #+(or lispworks4 lispworks5 lispworks6.0) nil
  #-(or lispworks4 lispworks5 lispworks6.0) t)

We have seen several problematic examples like this:

(defvar *feature-added-in-LispWorks-6.0*
  #+lispworks6 t
  #-lispworks6 nil)

which breaks in LispWorks 7.0, because that release does not contain the :lispworks6 feature.

In general you should use use the:lispworksx and :lispworksx.y features "in reverse". That is, make your code work for the latest version of LispWorks and then add conditionalization for any previous versions that you want to support, if needed.

Conditionalization for the LispWorks architectures

Every image from LispWorks 5.0 onwards has exactly one of the features :lispworks-32bit and :lispworks-64bit.

The two LispWorks architectures, 32-bit and 64-bit, can be distinguished by the features:lispworks-32bit or :lispworks-64bit.

Notes
  1. For a LispWorks image with the CAPI loaded, :capi will appear on *features*.
  2. LispWorks for Macintosh supports the native macOS Cocoa-based GUI and the X11/GTK+ GUI. If you need to test for which of these libraries is loaded, check for the features :cocoa and :gtk. The X11/Motif GUI is also available by evaluating (require "capi-motif") in the GTK+ image.
  3. Sometimes it is necessary to write code that examines *features* at load-time or run-time. For example this is true when you put platform-dependent code in fasl files that are shared between multiple platforms.
See also

*features* in the Common Lisp HyperSpec


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:30