<!--
  - Authors:
  -   Denys Duchier <duchier@ps.uni-sb.de>
  -   Leif Kornstaedt <kornstae@ps.uni-sb.de>
  -   Christian Schulte <schulte@ps.uni-sb.de>
  -
  - Contributors:
  -   Daniel Simon <dansim@ps.uni-sb.de> (SGML Translation)
  -
  - Copyright:
  -   Denys Duchier, Leif Kornstaedt, and Christian Schulte, 1998
  -
  - Last change:
  -   $Date: 2005-02-15 14:21:58 +0100 (Tue, 15 Feb 2005) $ by $Author: raph $
  -   $Revision: 16082 $
  -
  - This file is part of Mozart, an implementation of Oz 3:
  -   http://www.mozart-oz.org
  -
  - See the file "LICENSE" or
  -   http://www.mozart-oz.org/LICENSE.html
  - for information on usage and redistribution
  - of this file, and for a DISCLAIMER OF ALL
  - WARRANTIES.
  -
  -->

<Chapter id="chapter.chunks">
  <Title/Chunks/
  <Section id="section.chunks.general">
    <Title/Chunks in General/
    <P>
      The module <Span class=index/<<Chunk>>/ contains procedures operating
      on chunks.
      <List>
	<Entry><Span class=index/<<.>>/
	  <Index/<<Value>><And><<'.'>>/
	<Synopsis>
	  <<{Value.'.' ?+{RC} ?+{LI} ?_{X}}>>
	<Item>
	  returns the field&nbsp;?_{X} of&nbsp;?_{RC} at feature&nbsp;?_{LI}.

	<Entry><Span class=index/<<HasFeature>>/
	  <Index/<<Value>><And><<hasFeature>>/
	<Synopsis>
	  <<{Value.hasFeature ?+{RC} ?+{LI} ??{B}}>>
	<Item>
	  tests whether ?_{RC} has feature&nbsp;?_{LI}.

	<Entry><Span class=index/<<CondSelect>>/
	  <Index/<<Value>><And><<condSelect>>/
	<Synopsis>
	  <<{Value.condSelect ?+{RC} ?+{LI} ?_{X} ?_{Y}}>>
	<Item>
	  returns the field&nbsp;?_{Y} of&nbsp;?_{RC} at&nbsp;?_{LI}, if
	  ?_{RC} has feature&nbsp;?_{LI}.  Otherwise, returns&nbsp;?_{X}.

	<Entry><Span class=index/<<IsChunk>>/
	  <Index class=tails/<<Chunk>><And><<is>>/
	<Synopsis>
	  <<{Chunk.is ?+{X} ??{B}}>>
	<Item>
	  tests whether ?_{X} is a chunk.

	<Entry><Span class=index/<<NewChunk>>/
	  <Index class=tails/<<Chunk>><And><<new>>/
	<Synopsis>
	  <<{Chunk.new ?+{R} ??{C}}>>
	<Item>
	  returns a new chunk with the same features and fields as&nbsp;?_{R}.
      </List>

  <Section id="section.chunks.arrays">
    <Title/Arrays/
    <P>
      The module <Span class=index/<<Array>>/ contains procedures operating
      on arrays.  Whenever an array access is indexed with an illegal key, an
      error exception is raised.
      <List>
	<Entry><Span class=index/<<IsArray>>/
	  <Index class=tails/<<Array>><And><<is>>/
	<Synopsis>
	  <<{Array.is ?+{X} ??{B}}>>
	<Item>
	  tests whether ?_{X} is an array.

	<Entry><Span class=index/<<NewArray>>/
	  <Index class=tails/<<Array>><And><<new>>/
	<Synopsis>
	  <<{Array.new ?+{LowI} ?+{HighI} ?_{InitX} ??{Array}}>>
	<Item>
	  returns a new array with key range from ?_{LowI} to ?_{HighI}
	  including both.  All items are initialized to ?_{InitX}.

	<Entry><Span class=index/<<Put>>/
	  <Index/<<Array>><And><<put>>/
	<Synopsis>
	  <<{Array.put ?+{Array} ?+{I} ?_{X}}>>
	<Item>
	  sets the item of ?_{Array} under key&nbsp;?_{I} to&nbsp;?_{X}.

	<Entry><Span class=index/<<Get>>/
	  <Index/<<Array>><And><<get>>/
	<Synopsis>
	  <<{Array.get ?+{Array} ?+{I} ?_{X}}>>
	<Item>
	  returns the item of ?_{Array} under key&nbsp;?_{I}.

	<Entry><Span class=index/<<exchange>>/
	  <Index/<<Array>><And><<exchange>>/
	<Synopsis>
	  <<{Array.exchange ?+{Array} ?+{I} ?_{OldVal} ?_{NewVal}}>>
	<Item>
	  returns the current value of ?_{Array} under key&nbsp;?_{I}
          as item&nbsp;?_{OldVal} and updates the value of ?_{Array}
          under key&nbsp;?_{I} to be&nbsp;?_{NewVal}.

	<Entry><<low>>
	  <Index class=tails/<<Array>><And><<low>>/
	<Synopsis>
	  <<{Array.low ?+{Array} ??{LowI}}>>
	<Item>
	  returns the lower bound of the key range of ?_{Array}.

	<Entry><<high>>
	  <Index class=tails/<<Array>><And><<high>>/
	<Synopsis>
	  <<{Array.high ?+{Array} ??{HighI}}>>
	<Item>
	  returns the upper bound of the key range of ?_{Array}.

	<Entry><<clone>>
	  <Index class=tails/<<Array>><And><<clone>>/
	<Synopsis>
	  <<{Array.clone ?+{A1} ??{A2}}>>
	<Item>
	  returns a new array with the same bounds and contents as&nbsp;?_{A1}.

	<Entry><<toRecord>>
	  <Index class=tails/<<Array>><And><<toRecord>>/
	<Synopsis>
	  <<{Array.toRecord ?+{L} ?+{A} ??{R}}>>
	<Item>
	  returns a record with label&nbsp;L that contains as features the
	  integers between <<{Array.low ?_{A}}>> and <<{Array.high ?_{A}}>>
	  and with the corresponding fields.
      </List>

  <Section id="section.chunks.dictionaries">
    <Title/Dictionaries/
    <P>
      The module <Span class=index/<<Dictionary>>/ contains procedures
      operating on dictionaries.  If a dictionary contains an item under
      some key&nbsp;?_{LI}, we say ?_{LI} is a <Def/valid key/.  Whenever
      a dictionary access is indexed with an ill-typed key, a type error is
      raised. For a missing but well-typed key, a system exception is raised.
      <List>
	<Entry><Span class=index/<<IsDictionary>>/
	  <Index class=tails/<<Dictionary>><And><<is>>/
	<Synopsis>
	  <<{Dictionary.is ?+{X} ??{B}}>>
	<Item>
	  tests whether ?_{X} is a dictionary.

	<Entry><Span class=index/<<NewDictionary>>/
	  <Index class=tails/<<Dictionary>><And><<new>>/
	<Synopsis>
	  <<{Dictionary.new ??{Dictionary}}>>
	<Item>
	  returns a new empty dictionary.

	<Entry><<put>>
	  <Index class=tails/<<Dictionary>><And><<put>>/
	<Synopsis>
	  <<{Dictionary.put ?+{Dictionary} ?+{LI} ?_{X}}>>
	<Item>
	  sets the item in ?_{Dictionary} under key&nbsp;?_{LI} to&nbsp;?_{X}.

	<Entry><<get>>
	  <Index class=tails/<<Dictionary>><And><<get>>/
	<Synopsis>
	  <<{Dictionary.get ?+{Dictionary} ?+{LI} ?_{X}}>>
	<Item>
	  returns the item&nbsp;?_{X} of ?_{Dictionary} under key&nbsp;?_{LI}.

	<Entry><<condGet>>
	  <Index class=tails/<<Dictionary>><And><<condGet>>/
	<Synopsis>
	  <<{Dictionary.condGet ?+{Dictionary} ?+{LI} ?_{DefVal} ?_{X}}>>
	<Item>
	  returns the item&nbsp;?_{X} of ?_{Dictionary} under key&nbsp;?_{LI},
	  if ?_{LI} is a valid key of ?_{Dictionary}.  Otherwise,
	  returns&nbsp;?_{DefVal}.

	<Entry><<exchange>>
	  <Index class=tails/<<Dictionary>><And><<exchange>>/
	<Synopsis>
	  <<{Dictionary.exchange ?+{Dictionary} ?+{LI} ?_{OldVal} ?_{NewVal}}>>
	<Item>
	  returns the current value of ?_{Dictionary} under
	  key&nbsp;?_{LI} as item&nbsp;?_{OldVal} and updates the
	  value of ?_{Dictionary} under key&nbsp;?_{LI} to be ?_{NewVal}.
    
	<Entry><<condExchange>>
	  <Index class=tails/<<Dictionary>><And><<condExchange>>/
	<Synopsis>
	  <<{Dictionary.condExchange ?+{Dictionary} ?+{LI} ?_{DefVal}
	  ?_{OldVal} ?_{NewVal}}>>
	<Item>
	  If ?_{LI} is a valid key of ?_{Dictionary} then returns the
	  current value of ?_{Dictionary} under key&nbsp;?_{LI} as
	  item&nbsp;?_{OldVal} otherwise,  returns ?_{DefVal} as 
          item&nbsp;?_{OldVal}. Sets the value of ?_{Dictionary}
	  under key&nbsp;?_{LI} to be ?_{NewVal}. 

	<Entry><<keys>>
	  <Index class=tails/<<Dictionary>><And><<keys>>/
	<Synopsis>
	  <<{Dictionary.keys ?+{Dictionary} ??{LIs}}>>
	<Item>
	  returns a list of all currently valid keys of ?_{Dictionary}.

	<Entry><<entries>>
	  <Index class=tails/<<Dictionary>><And><<entries>>/
	<Synopsis>
	  <<{Dictionary.entries ?+{Dictionary} ??{Ts}}>>
	<Item>
	  returns the list of current entries of ?_{Dictionary}.  An entry is a
	  pair <<?_{LI}#?_{X}>>, where ?_{LI} is a valid key of ?_{Dictionary}
	  and ?_{X} the corresponding item.

	<Entry><<items>>
	  <Index class=tails/<<Dictionary>><And><<items>>/
	<Synopsis>
	  <<{Dictionary.items ?+{Dictionary} ??{Xs}}>>
	<Item>
	  returns the list of all items currently in ?_{Dictionary}.

	<Entry><<isEmpty>>
	  <Index class=tails/<<Dictionary>><And><<isEmpty>>/
	<Synopsis>
	  <<{Dictionary.isEmpty ?+{Dictionary} ??{B}}>>
	<Item>
	  tests whether ?_{Dictionary} currently contains an entry.

	<Entry><<remove>>
	  <Index class=tails/<<Dictionary>><And><<remove>>/
	<Synopsis>
	  <<{Dictionary.remove ?+{Dictionary} ?+{LI}}>>
	<Item>
	  removes the item under key&nbsp;?_{LI} from ?_{Dictionary} if
	  ?_{LI} is a valid key.  Otherwise, does nothing.

	<Entry><<removeAll>>
	  <Index class=tails/<<Dictionary>><And><<removeAll>>/
	<Synopsis>
	  <<{Dictionary.removeAll ?+{Dictionary}}>>
	<Item>
	  removes all entries currently in ?_{Dictionary}.

	<Entry><<member>>
	  <Index class=tails/<<Dictionary>><And><<member>>/
	<Synopsis>
	  <<{Dictionary.member ?+{Dictionary} ?+{LI} ??{B}}>>
	<Item>
	  tests whether ?_{LI} is a valid key of ?_{Dictionary}.

	<Entry><<clone>>
	  <Index class=tails/<<Dictionary>><And><<clone>>/
	<Synopsis>
	  <<{Dictionary.clone ?+{Dictionary1} ??{Dictionary2}}>>
	<Item>
	  returns a new dictionary ?_{Dictionary2} containing the currently
	  valid keys and corresponding items of ?_{Dictionary1}.

	<Entry><<toRecord>>
	  <Index class=tails/<<Dictionary>><And><<toRecord>>/
	<Synopsis>
	  <<{Dictionary.toRecord ?+{L} ?+{Dictionary} ??{R}}>>
	<Item>
	  returns a record&nbsp;?_{R} with label&nbsp;?_{L} whose features
	  and their fields correspond to the keys and their entries of
	  ?_{Dictionary}.

        <Entry><<weak>>
          <Index class=tails/<<Dictionary>><And><<weak>>/
        <Item>
          another way to access module <code/WeakDictionary/ (see
<ptr to=section.chunks.weakdictionaries>).
      </List>

  <Section id="section.chunks.weakdictionaries">
    <Title/Weak Dictionaries/
    <P>
      The module <Span class=index/<<WeakDictionary>>/ contains procedures
      operating on weak dictionaries.  A weak dictionary is much like
an ordinary dictionary and supports the same API.  The main
difference is that an entry is kept only as long as its item (&ie; the
value recorded under the key) has not become garbage.  If the item is
only reachable through one or more weak dictionaries, the
corresponding entries will automatically be dropped from all weak
dictionaries at the next garbage collection.

    <para><title/Finalization Stream/
Each weak dictionary is associated with a <em/finalization stream/.
When an item ?_{X} (indexed under ?_{Key}) becomes garbage, the entry
is automatically removed from the
weak dictionary at the next garbage collection and the pair
<code/Key#X/ is sent on to the
finalization stream (as if the weak dictionary were associated with a
port and the pair was sent to it using <code/Port.send/).  This
means that the item, which was garbage, becomes again non-garbage
when it is sent to the finalization stream.  If subsequently, this
last remaining reference disappears, then the item really becomes
garbage since it won't be referenced even through a weak dictionary.

    <p>The
finalization stream is created at the same time as the weak
dictionary; both are output arguments of <code/NewWeakDictionary/.  If
you are not interested in the finalization stream, you can explicitly
close it using <code/WeakDictionary.close/.

    <p>Module <code/WeakDictionary/ can also be accessed as
<code/Dictionary.weak/.
      <List>
	<Entry><Span class=index/<<IsWeakDictionary>>/
	  <Index class=tails/<<WeakDictionary>><And><<is>>/
	<Synopsis>
	  <<{WeakDictionary.is ?+{X} ??{B}}>>
	<Item>
	  tests whether ?_{X} is a weak dictionary.

	<Entry><Span class=index/<<NewWeakDictionary>>/
	  <Index class=tails/<<WeakDictionary>><And><<new>>/
	<Synopsis>
	  <<{WeakDictionary.new ??{L} ??{Weak}}>>
	<Item>
	  has the same arguments as <ref to=port.new/<code/Port.new//.
	  Returns a new empty weak dictionary associated with a new
finalization stream <code/L/.

        <Entry><<close>>
          <Index class=tails/<<WeakDictionary>><And><<close>>/
        <Synopsis>
          <<{WeakDictionary.close ?+{Weak}}>>
        <Item>
          drops the finalization stream (if any).  After this, any
          entry that becomes garbage is simply dropped instead of
          being sent to the finalization stream. Note that the
          ?_{close}, ?_{put}, ?_{remove}, and ?_{removeAll} operations
          cannot be used in a (subordinated) space other than where
          the weak dictionary has been constructed.

	<Entry><<put>>
	  <Index class=tails/<<WeakDictionary>><And><<put>>/
	<Synopsis>
	  <<{WeakDictionary.put ?+{Weak} ?+{LI} ?_{X}}>>
	<Item>
	  sets the item in ?_{Weak} under key&nbsp;?_{LI} to&nbsp;?_{X}.

	<Entry><<get>>
	  <Index class=tails/<<WeakDictionary>><And><<get>>/
	<Synopsis>
	  <<{WeakDictionary.get ?+{Weak} ?+{LI} ?_{X}}>>
	<Item>
	  returns the item&nbsp;?_{X} of ?_{Weak} under key&nbsp;?_{LI}.

	<Entry><<condGet>>
	  <Index class=tails/<<WeakDictionary>><And><<condGet>>/
	<Synopsis>
	  <<{WeakDictionary.condGet ?+{Weak} ?+{LI} ?_{X} ?_{Y}}>>
	<Item>
	  returns the item&nbsp;?_{Y} of ?_{Weak} under key&nbsp;?_{LI},
	  if ?_{LI} is a valid key of ?_{Weak}.  Otherwise,
	  returns&nbsp;?_{X}.

	<Entry><<exchange>>
	  <Index class=tails/<<WeakDictionary>><And><<exchange>>/
	<Synopsis>
	  <<{WeakDictionary.exchange ?+{Weak} ?+{LI} ?_{OldVal} ?_{NewVal}}>>
	<Item>
	  returns the current value of ?_{Weak} under
	  key&nbsp;?_{LI} as item&nbsp;?_{OldVal} and updates the
	  value of ?_{Weak} under key&nbsp;?_{LI} to be ?_{NewVal}.
    
	<Entry><<condExchange>>
	  <Index class=tails/<<WeakDictionary>><And><<condExchange>>/
	<Synopsis>
	  <<{WeakDictionary.condExchange ?+{Weak} ?+{LI} ?_{DefVal}
	  ?_{OldVal} ?_{NewVal}}>>
	<Item>
	  If ?_{LI} is a valid key of ?_{Weak} then returns the
	  current value of ?_{Weak} under key&nbsp;?_{LI} as
	  item&nbsp;?_{OldVal} otherwise,  returns ?_{DefVal} as 
          item&nbsp;?_{OldVal}. Sets the value of ?_{Weak}
	  under key&nbsp;?_{LI} to be ?_{NewVal}. 

	<Entry><<keys>>
	  <Index class=tails/<<WeakDictionary>><And><<keys>>/
	<Synopsis>
	  <<{WeakDictionary.keys ?+{Weak} ??{LIs}}>>
	<Item>
	  returns a list of all currently valid keys of ?_{Weak}.

	<Entry><<entries>>
	  <Index class=tails/<<WeakDictionary>><And><<entries>>/
	<Synopsis>
	  <<{WeakDictionary.entries ?+{Weak} ??{Ts}}>>
	<Item>
	  returns the list of current entries of ?_{Weak}.  An entry is a
	  pair <<?_{LI}#?_{X}>>, where ?_{LI} is a valid key of ?_{Weak}
	  and ?_{X} the corresponding item.

	<Entry><<items>>
	  <Index class=tails/<<WeakDictionary>><And><<items>>/
	<Synopsis>
	  <<{WeakDictionary.items ?+{Weak} ??{Xs}}>>
	<Item>
	  returns the list of all items currently in ?_{Weak}.

	<Entry><<isEmpty>>
	  <Index class=tails/<<WeakDictionary>><And><<isEmpty>>/
	<Synopsis>
	  <<{WeakDictionary.isEmpty ?+{Weak} ??{B}}>>
	<Item>
	  tests whether ?_{Weak} currently contains an entry.

	<Entry><<remove>>
	  <Index class=tails/<<WeakDictionary>><And><<remove>>/
	<Synopsis>
	  <<{WeakDictionary.remove ?+{Weak} ?+{LI}}>>
	<Item>
	  removes the item under key&nbsp;?_{LI} from ?_{Weak} if
	  ?_{LI} is a valid key.  Otherwise, does nothing.

	<Entry><<removeAll>>
	  <Index class=tails/<<WeakDictionary>><And><<removeAll>>/
	<Synopsis>
	  <<{WeakDictionary.removeAll ?+{Weak}}>>
	<Item>
	  removes all entries currently in ?_{Weak}.

	<Entry><<member>>
	  <Index class=tails/<<WeakDictionary>><And><<member>>/
	<Synopsis>
	  <<{WeakDictionary.member ?+{Weak} ?+{LI} ??{B}}>>
	<Item>
	  tests whether ?_{LI} is a valid key of ?_{Weak}.

	<Entry><<toRecord>>
	  <Index class=tails/<<WeakDictionary>><And><<toRecord>>/
	<Synopsis>
	  <<{WeakDictionary.toRecord ?+{L} ?+{Weak} ??{R}}>>
	<Item>
	  returns a record&nbsp;?_{R} with label&nbsp;?_{L} whose features
	  and their fields correspond to the keys and their entries of
	  ?_{Weak}.
      </List>

  <Section id="section.chunks.bitarrays">
    <Title/Bit Arrays/
    <P>
      The module <Span class=index/<<BitArray>>/ contains procedures operating
      on arrays of bits (&ie;, units of information each being either <Def/set/
      or <Def/reset/).
<list>
	<entry/<span class=index/<code/IsBitArray//
<index class=tails/<code/BitArray/<and><code/is///
	<synopsis/<code/{BitArray.is ?+{X} ??{B}}//
	<item/tests whether ?_{X} is a bit array./

	<entry/<code/new/
<index class=tails/<code/BitArray/<and><code/new///
	<synopsis/<code/{BitArray.new ?+{LowI} ?+{HighI} ??{BitArray}}//
	<item/creates an new ?_{BitArray} with lower bound ?_{LowI}
and upper bound ?_{HighI}, and all bits initially cleared.  This
interface is identical to that of general Oz arrays./

	<entry/<code/set/
<index class=tails/<code/BitArray/<and><code/set///
	<synopsis/<code/{BitArray.set ?+{BitArray} ?+{I}}//
	<item/sets bit&nbsp;?_{I} of ?_{BitArray}./

	<entry/<code/clear/
<index class=tails/<code/BitArray/<and><code/clear///
	<synopsis/<code/{BitArray.clear ?+{BitArray} ?+{I}}//
	<item/clears bit&nbsp;?_{I} of ?_{BitArray}./

	<entry/<code/test/
<index class=tails/<code/BitArray/<and><code/test///
	<synopsis/<code/{BitArray.test ?+{BitArray} ?+{I} ??{B}}//
	<item/tests whether bit&nbsp;?_{I} of ?_{BitArray} is
set./

	<entry/<code/low/
<index class=tails/<code/BitArray/<and><code/low///
	<synopsis/<code/{BitArray.low ?+{BitArray} ??{LowI}}//
	<item/returns the lower bound ?_{LowI} of ?_{BitArray}./

	<entry/<code/high/
<index class=tails/<code/BitArray/<and><code/high///
	<synopsis/<code/{BitArray.high ?+{BitArray} ??{HighI}}//
	<item/returns the upper bound ?_{HighI} of ?_{BitArray}./

	<entry/<code/clone/
<index class=tails/<code/BitArray/<and><code/clone///
	<synopsis/<code/{BitArray.clone ?+{BitArray1} ??{BitArray2}}//
	<item/returns a new bit array that is a copy of its first
argument./

	<entry/<code/disj/
<index class=tails/<code/BitArray/<and><code/disj///
	<synopsis/<code/{BitArray.disj ?+{BitArray1} ?+{BitArray2}}//
	<item/side-effects its first argument with the bitwise <q/or/ of
the two arguments./

	<entry/<code/conj/
<index class=tails/<code/BitArray/<and><code/conj///
	<synopsis/<code/{BitArray.conj ?+{BitArray1} ?+{BitArray2}}//
	<item/side-effects its first argument with the bitwise <q/and/ of
the two arguments./

	<entry/<code/nimpl/
<index class=tails/<code/BitArray/<and><code/nimpl///
	<synopsis/<code/{BitArray.nimpl ?+{BitArray1} ?+{BitArray2}}//
	<item/side-effects its first argument with the bitwise <q/and/ of
the the first argument and the negation of the second argument (&ie;,
negated implication)./

	<entry/<code/disjoint/
<index class=tails/<code/BitArray/<and><code/disjoint///
	<synopsis/<code/{BitArray.disjoint ?+{BitArray1} ?+{BitArray2} ??{B}}//
	<item/tests whether the bit arrays have no set bits in common./

	<entry/<code/card/
<index class=tails/<code/BitArray/<and><code/card///
	<synopsis/<code/{BitArray.card ?+{BitArray} ??{I}}//
	<item/returns the number of set bits./

	<entry/<code/toList/
<index class=tails/<code/BitArray/<and><code/toList///
	<synopsis/<code/{BitArray.toList ?+{BitArray} ??{L}}//
	<item/returns the list of indices for all set bits in ?_{BitArray}./

	<entry/<code/complementToList/
<index class=tails/<code/BitArray/<and><code/complementToList///
	<synopsis/<code/{BitArray.complementToList ?+{BitArray} ??{L}}//
	<item/returns the list of indices for all cleared bits in
?_{BitArray}./

      </list></p>
  </section>

  <Section id="section.chunks.ports">
    <Title/Ports/
    <P>
      The module <Span class=index/<<Port>>/ contains procedures operating on
      ports.
      <List>
	<Entry><Span class=index/<<IsPort>>/
	  <Index class=tails/<<Port>><And><<is>>/
	<Synopsis>
	  <<{Port.is ?+{X} ??{B}}>>
	<Item>
	  tests whether ?_{X} is a port.

	<Entry id=port.new><Span class=index/<<NewPort>>/
	  <Index class=tails/<<Port>><And><<new>>/
	<Synopsis>
	  <<{Port.new ??{Xs} ??{Port}}>>
	<Item>
	  returns a new port, together with its associated stream&nbsp;?_{Xs}.

	<Entry><Span class=index/<<Send>>/
	  <Index/<<Port>><And><<send>>/
	<Synopsis>
	  <<{Port.send ?+{Port} ?_{X}}>>
	<Item>
	  sends ?_{X} to the port ?_{Port}:  The stream pointed to by
	  ?_{Port} is unified with <<?_{X}|_>> (in a newly created thread),
	  and the pointer advances to the stream's new tail.

	<Entry><Span class=index/<<SendRecv>>/
	  <Index/<<Port>><And><<sendRecv>>/
	<Synopsis>
	  <<{Port.sendRecv ?+{Port} ?_{X} ?_{Y}}>>
	<Item>
	  sends the pair <<?_{X}#?_{Y}>> to the port ?_{Port}:  The stream pointed to by
	  ?_{Port} is unified with <<?_{X}#?_{Y}|_>> (in a newly created thread),
	  and the pointer advances to the stream's new tail. 
        <p>The argument ?_{X} is commonly used as message to be sent, while ?_{Y} serves as reply to that message.
      </List>

  <Section id="section.chunks.locks">
    <Title/Locks/
    <P>
      The module <Span class=index/<<Lock>>/ contains procedures for locks.
      <List>
	<Entry><Span class=index/<<IsLock>>/
	  <Index class=tails/<<Lock>><And><<is>>/
	<Synopsis>
	  <<{Lock.is ?+{X} ??{B}}>>
	<Item>
	  tests whether ?_{X} is a lock.

	<Entry><Span class=index/<<NewLock>>/
	  <Index class=tails/<<Lock>><And><<new>>/
	<Synopsis>
	  <<{Lock.new ??{LockC}}>>
	<Item>
	  creates and returns a new lock.
      </List>

  <Section id="section.chunks.classes">
    <Title/Classes/
    <P>
      The module <Span class=index/<<Class>>/ contains procedures operating
      on classes.
      <List>
	<Entry><Span class=index/<<IsClass>>/
	  <Index class=tails/<<Class>><And><<is>>/
	<Synopsis>
	  <<{Class.is ?+{X} ??{B}}>>
	<Item>
	  tests whether ?_{X} is a class.

	<Entry><<new>>
	  <Index class=tails/<<Class>><And><<new>>/
	<Synopsis>
	  <<{Class.new ?+{ParentKs} ?+{AttrR} ?+{FeatR} ?+{PropAs} ??{K}}>>
	<Item>
	  creates a new class by inheriting from ?_{ParentKs} with new
	  attributes ?_{AttrR} and new features ?_{FeatR}. The fields
	  with integer features in ?_{AttrR} define the free
	  attributes. The fields with literal features define
	  attributes with initial values, where the feature is the
	  attribute name and the field its initial value. The
	  semantics for ?_{FeatR} is accordingly. The properties of the class 
          to be created are defined by ?_{PropAs} (a list of atoms, valid 
          elements are <<sited>>, <<final>>, and <<locking>>). 
        <p>
          For example, the statement
<<<C={Class.new [D E] a(a:1 b) f(f:2 g) [final]}>>>
          is equivalent to
<<<class C from D E
   prop final
   attr a:1 b
   feat f:2 g
end>>>
     
	<Entry><<getAttr>>
	  <Index class=tails/<<Class>><And><<getAttr>>/
	<Synopsis>
	  <<{Class.getAttr ?+{K} ?+{LI} ??{X}}>>
	<Item>
          Returns the initival value ?_{X} for attribute ?_{LI} as defined by the class ?_{K}.
        <p>
          For example, the statement
<<<{Class.getAttr class attr a:4 end a}>>>
          returns <<4>>.
     

      </List>

  <Section id="section.chunks.objects">
    <Title/Objects/
    <P>
      The module <Span class=index/<<Object>>/ contains procedures operating
      on objects.
    <P>
      The system procedures that define the behaviour of &Oz; objects and
      classes are also given in this section.
      <List>
	<Entry><Span class=index/<<IsObject>>/
	  <Index class=tails/<<Object>><And><<is>>/
	<Synopsis>
	  <<{Object.is ?+{X} ??{B}}>>
	<Item>
	  tests whether ?_{X} is an object.

	<Entry><Span class=index/<<New>>/
	  <Index class=tails/<<Object>><And><<new>>/
	<Synopsis>
	  <<{Object.new ?+{K} ?+{InitMessageR} ??{O}}>>
	<Item>
	  Creates a new object from class&nbsp;?_{K} with initial message
	  ?_{InitMessageR}.

      </List>
    <SubSection class=unnumbered>
      <Title/The <<BaseObject>> Class/
      <P>
	<Index class=tails/<<Object>><And><<base>>/
	The class <Span class=index/<<BaseObject>>/ defines the following
	method.
	<List>
	  <Entry><<noop>>
	    <Index/<<Object>><And><<base>><And><<noop>>/
	  <Synopsis>
	    <<noop()>>
	  <Item>
	    does nothing.  It is defined as <<meth noop() skip end>>.
	</List>

  <Section id="section.chunks.functors">
    <Title/Functors/
    <P>
      The module <Span class=index/<<Functor>>/ contains procedures operating
      on functors.
      <List>
	<Entry><<is>>
	  <Index class=tails/<<Functor>><And><<is>>/
	<Synopsis>
	  <<{Functor.is ?+{X} ??{B}}>>
	<Item>
	  tests whether ?_{X} is a functor.

	<Entry><<new>>
	  <Index class=tails/<<Functor>><And><<new>>/
	<Synopsis>
	  <<{Functor.new ?={import spec} ?={export spec} ?+{P} ??{Functor}}>>
	<Item>
	  returns a new functor with imports as described by the
	  ?={import spec}, exports as described by the ?={export spec},
	  and body as performed by&nbsp;?_{P}.
	<P>
	  The ?={import spec} is a record mapping the name of each
	  imported module to a record giving information about it:
	  <Grammar.Rule class=compact>?={import spec}
	    <Grammar.Alt
	      /<<'import'(?={module name}: ?={import info} &ellipsis;>>/
	    <Grammar.Alt type=space
	      /<<         ?={module name}: ?={import info})>>/
	  <Grammar.Rule>?={module name}
	    <Grammar.Alt/?={atom}/
	<P>
	  The optional <<'from'>> field gives the value of this import's
	  <<at>> clause, if given:
	  <Grammar.Rule>?={import info}
	    <Grammar.Alt
	      /<<info(type: ?={type} >>[<<'from': ?={atom}>>]<<)>>/
	<P>
	  The <<type>> field is the expected type of the module.
	  This can be any of the atoms returned by <<Value.type>>,
	  plus some more implementation-specific ones, or a record
	  with label <<record>>:
	<P>
	  <Grammar.Rule class=compact>?={type}
	    <Grammar.Alt
	      /<<int>> | <<atom>> | &ellipsis;<Grammar.Note/see above//
	    <Grammar.Alt
/<<record(?={feature}: ?={type} &ellipsis; ?={feature}: ?={type})>>/
	    <Grammar.Alt
	      /<<nil>><Grammar.Note/no information known/
	<P>
	  The ?={export spec} is a record mapping each feature of the
	  module resulting from applications of this functor to the
	  type of the corresponding value:
	  <Grammar.Rule>?={export spec}
	    <Grammar.Alt
/<<'export'(?={feature}: ?={type} &ellipsis; ?={feature}: ?={type})>>/
	<P>
	  The body is a binary procedure <<{P ?={import} ?={export}}>>
	  where:
	  <Grammar.Rule>?={import}
	    <Grammar.Alt
/<<'IMPORT'(?={module name}: ?={value} &ellipsis; ?={module name}: ?={value})>>/
	  <Grammar.Rule>?={export}
	    <Grammar.Alt/?={value}/
      </List>
</Chapter>

<!--
Local Variables:
mode: sgml
mode: auto-fill
sgml-default-dtd-file: "chapter.ced"
sgml-auto-activate-dtd: t
adaptive-fill-mode: nil
End:
-->

