::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:
class Type.Common.Public  public Gilda

  type Bit  in  0 to 1                :Boolean enumeration

  type File  is                       &File I/O that will automatically close
    - *Id = 0   byte,                 &Opaque file id (at void)

      Open      => @$Id ~= 0,         &True if the file is open; else False.
      Status    => Status($),         &Current status

      Line      => Status($) = #A,    &Input at the end of a line
      End       => Status($) = #B,    &Input at the end of a file
      Past      => Status($) = #C,    &Input past the end of a file
      In        => Status($) = #D,    &Input with more to go
      Out       => Status($) = #E,    &Open for output
      Direct    => Status($) = #F,    &Open for random access

      Error     => Status($) _=> #10, &File states after an exception:
                                      &   OPEN:
      Missing   => Status($) = #10,   &The file does not exist.
      Directory => Status($) = #11,   &Can not open a directory as a file.
      Authority => Status($) = #12,   &Not permitted to access a path directory.
      Permit    => Status($) = #13,   &Not permitted to access a file or stream.
      Share     => Status($) = #14,   &The file or stream is in use by another.
      Many      => Status($) = #15,   &Too many files are open.

                                      &   INPUT, OPEN:
      Input     => Status($) = #16,   &Could not read from a file or stream.

                                      &   PRINT, CLOSE, OPEN:
      Flush     => Status($) = #17,   &Could not write to a file or stream.

                                      &   PRINT, CLOSE:
      Full      => Status($) = #18,   &The file system is full.
      Overflow  => Status($) = #19    :The output buffer overflowed.


  type Key  is                        &{string, string} pair
       Key   string,                  &Name of a symbol
       Tag   string                   :String associated with the symbol

  type Key..string  is                &{string, string} pair
       Key   string,                  &Name of a symbol
       Tag   string                   :String associated with the symbol


  type Key..word  is                  &{string, word} pair
       Key   string,                  &Name of a symbol
       Tag   word                     :Word associated with the symbol


  type At            is  @At  byte
  type Wiz           is  *At  byte

  type At..string    is  @At  string
  type At..byte      is  @At  byte
  type At..parcel    is  @At  parcel
  type At..word      is  @At  word
  type At..cell      is  @At  cell
  type At..single    is  @At  single
  type At..double    is  @At  double

  type Wiz..string   is  *At  string
  type Wiz..byte     is  *At  byte
  type Wiz..parcel   is  *At  parcel
  type Wiz..word     is  *At  word
  type Wiz..cell     is  *At  cell
  type Wiz..single   is  *At  single
  type Wiz..double   is  *At  double

  type At..At        is  @At  At
  type Wiz..Wiz      is  *At  Wiz

  type At..At..byte  is  @At  At..byte
  type Wiz..At..byte is  *At  At..byte

  type At.Self       is  *At  At.Self
:
:...............................................................................



::::::::::::::::::::::::::::::::  type/file/File  ::::::::::::::::::::::::::::::
:
function STATUS..File:  Status of a file or I/O stream.

 entry File[0]                :Handle for the stream passed by address.

  exit Status   byte          :Status code
:
:        Closed =  0   The file is closed
:        Eol    = #A   Sequential input at End Of Line
:        Eof    = #B   Sequential input at End of Stream
:        Peof   = #C   Sequential input at Past End of Stream
:        In     = #D   Sequential input at next byte to be read
:        Out    = #E   Sequential output
:        Direct = #F   Direct access
:...............................................................................
:
method CLOSE..File  pure:  See if a file is open and close it if it is.

change File               :An open file ID
:
:...............................................................................
:
method DRAIN..File  pure:  Close a file, but do not signal it is closed.

change File               :An open file ID
:
:...............................................................................
:
sequence READ.FILE:  Read a file as a sequence of bytes.

 entry Path    string       :Os relative file path.

  exit C       byte         :Each character
:
:...............................................................................
:
method CLOSE..Read.File:  Terminate the sequence and close the file.

change ~Read.File           :Sequence iterator
:
:...............................................................................
:
sequence READ.TEXT:  Read a text file as a sequence of strings.

 entry Path   string        :Os relative file path

  exit Text   string        :Each line of text without CR/LF
:
:...............................................................................
:
function STATUS..Read.Text:  Get the current status of the text file.

 entry ~Read.Text           :Sequence iterator

  exit Status    byte       :I/O stream status
:
:...............................................................................
:
method CLOSE..Read.Text:  Terminate the sequence and close the text file.

change ~Read.Text           :Sequence iterator
:
:...............................................................................



::::::::::::::::::::::::::::::::  type/key/Key  ::::::::::::::::::::::::::::::::
:
function FORM..Key..string:  Format a Key(string); primarily used for Tracing.

 entry Key..string[0],             &Key to format; its address is examined.
       Format = "{}"  string       :Optional first then last character

  exit Form  string                :Display format for the Key
:
:...............................................................................
:
function FORM..Key..word:  Format a Key(word); primarily used for Tracing.

 entry Key..word[0],               &Key to format; its address is examined.
       Format = "{}"  string       :Optional first then last character

  exit Form  string                :Display format for the Key
:
:...............................................................................



:::::::::::::::::::::::  type/dynamic/memory/Type.Memory  ::::::::::::::::::::::
:
method ALLOCATE_RAW  pure:  Allocate raw bytes.

  exit *Memory[ Size-1 ]   byte      :Memory that was allocated

 entry Size       word,              &Number of bytes to allocate
       Align = 0  word               :Alignment in bytes (power of 2)
:
:  If there is not enough memory available a Memory.Heap fault is raised.
:
:...............................................................................


end