## Primitive Types

## Overview

Primitive types have a single value, these include characters, numbers, and pointers. They are all symbols in the keyword package.

- `:char` - Signed 8-bits. A dereferenced :char pointer returns an character.

- `:unsigned-char` - Unsigned 8-bits. A dereferenced :unsigned-char pointer returns an character.

- `:byte` - Signed 8-bits. A dereferenced :byte pointer returns an integer.

- `:unsigned-byte` - Unsigned 8-bits. A dereferenced :unsigned-byte pointer returns an integer.

- `:short` - Signed 16-bits.

- `:unsigned-short` - Unsigned 16-bits.

- `:int` - Signed 32-bits.

- `:unsigned-int` - Unsigned 32-bits.

- `:long` - Signed 32 or 64 bits, depending upon the platform.

- `:unsigned-long` - Unsigned 32 or 64 bits, depending upon the platform.

- `:float` - 32-bit floating point.

- `:double` - 64-bit floating point.

- `:cstring` - A &NULL; terminated string used for passing and returning characters strings with a &C; function.

- `:void` - The absence of a value. Used to indicate that a function does not return a value.

- `:pointer-void` - Points to a generic object.

- `*` - Used to declare a pointer to an object

## `def-constant`

Binds a symbol to a constant.

### Macro

          def-constant
          name
          value
          &key;
          export

`name`

  A symbol that will be bound to the value.

`value`

  An evaluated form that is bound the the name.

`export`

  When &t;, the name is exported from the current package. The default is &nil;

### Description

This is a thin wrapper around `defconstant`. It evaluates at compile-time and optionally exports the symbol from the package.

### Examples

         (def-constant pi2 (* 2 pi))
         (def-constant exported-pi2 (* 2 pi) :export t)

### Side Effects

Creates a new special variable..

### Affected by

None.

### Exceptional Situations

None.

## `def-foreign-type`

Defines a new foreign type.

### Macro

          def-foreign-type
          name
          type

`name`

  A symbol naming the new foreign type.

`value`

  A form that is not evaluated that defines the new foreign type.

### Description

Defines a new foreign type.

### Examples

         (def-foreign-type my-generic-pointer :pointer-void)
         (def-foreign-type a-double-float :double-float)
         (def-foreign-type char-ptr (* :char))

### Side Effects

Defines a new foreign type.

### Affected by

None.

### Exceptional Situations

None.

## `null-char-p`

Tests a character for &NULL; value.

### Macro

          null-char-p
          char

`char`

  A character or integer.

returns

  A boolean flag indicating if char is a &NULL; value.

### Description

A predicate testing if a character or integer is &NULL;. This abstracts the difference in implementations where some return a `character` and some return a `integer` whence dereferencing a `C` character pointer.

### Examples

    (def-array-pointer ca :unsigned-char)
      (let ((fs (convert-to-foreign-string "ab")))
        (values (null-char-p (deref-array fs 'ca 0))
        (null-char-p (deref-array fs 'ca 2))))
    => &nil;
       &t;

### Side Effects

None.

### Affected by

None.

### Exceptional Situations

None.