;;;; Copyright 2002, Jonathan Bachrach.  See file TERMS.

(use goo/boot)
(use goo/macros)
(use goo/mag)
(use goo/types)
(use goo/math)
(use goo/runtime)
(use goo/cols)
(use goo/packer)
(use goo/io/write)
(use goo/io/read)
(use eval/syntax)
(use goo/io/port)

(export
 ;; Section 1.1/2.1: Special forms.
 IF SEQ SET FUN LET DEF LOC ESC FIN DV DM DG DP DC MACRO-EXPAND
 SUP APP-SUP QUOTE
 CT CT-ALSO DS USE USE/MANGLE USE/EXPORT USE/INCLUDE USE/LIBRARY EXPORT 
 DDV

 ;; Section 1.2/2.2: Macros.
 DF TRY REP MIF AND OR CASE CASE-BY COND MATCH UNLESS WHEN ASSERT
 FOR WHILE UNTIL OPF PUSHF POPF INCF DECF SWAPF ROTF
 OP PUB EXPORTED
 PACKING-WITH PACKING-IN PACKING PACK-IN PACK PACKED
 <PACKER> PACKER PACKER-FAB PACKER-ADD PACKER-RES
 RENEW     ;; TODO: TEMPORARY

 ;; Section 1.3: Read macros.
 quasiquote
 
 ;; Section 3.1: Any.
 <any> as new object-class clone
 
 ;; Section ?.?: Type.
 <type>
 <class>     class-parents class-children class-direct-props
             class-ancestors              class-props
             class-name
 <singleton> type-object
 <subclass>  type-class
 <union>     union-elts
 <product>   product-elts

 ;; Section 3.2: Comparables.
 == = < ~= ~== > <= >= min max subtype? isa? may-isa? 
 
 ;; Section 3.3: Null.
 nul ;; nul?
 
 ;; Section 3.4: Booleans.
 <log> not
 
 ;; Section 3.5: Characters.
 <chr> lower? upper? to-lower to-upper alpha?
 digit? to-digit eof-object?
 
 ;; Section 3.6: Numbers.
 ;; Not included: gcd, lcm (which seem to be missing).
 <num> + 1+ - 1- * / floor ceil round trunc floor/ ceil/ round/
 trunc/ mod mod+ modincf rem div pos? zero? neg? neg abs *print-base*
 num-to-str num-to-str-base str-to-num
 log logn pow sqrt isqrt sin cos tan asin acos atan atan2 sinh cosh tanh $pi $e
 <int> #| ^ & ~ bit? even? odd? << >> >>> $max-int $min-int
 <flo> flo-bits
 <loc> loc-val loc-val-setter address-of
 
 ;; Section 3.7: Collections.
 <col> <col.> len elt elt-or elts low-elt dup col-res col-res-type
 empty? empty elt-default elt-type key-type key-test fab fabs fill any?
 all? fold fold+ find find-or del zap do do2 map map2 do-keyed
 map-keyed mem? keys items zap find find-or 
 <col!> del! add! zap! fill! into
 elt-setter low-elt-setter len-setter len/fill-setter 
 ;; 3.7.1: Iteration protocol.
 <enum> enum fin? nxt now now-setter now-key
 ;; 3.7.2: Maps.
 <map> col ;; <assocs> assocs-test
 <tab> tab-growth-factor tab-growth-threshold tab-shrink-threshold
 tab-hash id-hash ;; $permanent-hash-state tab-gc-state 
 <str-tab> case-insensitive-string-hash case-insensitive-string-equal
 <set>
 ;; 3.7.3: Sequences.
 <seq> <seq.> add 1st 2nd 3rd last pos rev cat cat2 sub push pop
 pick reject ins del-vals del-dups finds sort sort-by 
 prefix? suffix? repeat split join
 <seq!>  add! rev! cat! sub-setter push! pop! del-vals! del-dups! sort! sort-by!
 ;; 3.7.4 Tuples.
 <tup> tup
 ;; 3.7.5 (the first one): Lists.
 <lst> <list> head head-setter tail tail-setter lst list pair nil push! pop!
 ;; 3.7.5 (the second one): Optionals.
 <opts>
 ;; 3.7.6 (the first one): Flat sequences.
 <flat> <str> str to-str <vec> vec 
 low-elt low-elt-setter
 ;; 3.7.6 (the second one):  Ranges.
 <range> range range-by from below
 ;; 3.7.7: Steps.
 <step> first-then
 <each> each
 <zip> zip unzip
 <cycle> cycle
 
 ;; Section 3.8: Symbols.
 <sym> as cat-sym gensym fab-setter-name var-name var-type

 ;; Section 3.9: Props.
 <prop> prop-owner prop-getter prop-setter prop-type prop-init
 prop-value prop-value-setter prop-bound? find-getter find-setter add-prop

 ;; Section 3.10: Functions.
 <fun> fun-name fun-names fun-specs fun-nary? fun-arity fun-val
 identity compose curry rcurry always app 
 <gen> fun-mets gen-add-met ord-app-mets
 <met> met-app?

 ;; Section 3.11: Conditions.
 <condition> default-handler sig <simple-condition> condition-message
 condition-arguments <serious-condition> <error> error <simple-error>
 <handler> handler-function fab-handler handler-matches?
 <restart>

 ;; Section 3.12: Ports.
 <port> <in-port> get gets peek ready? port-line
 in out open close with-port
 <out-port> newline force-out put puts
 <file-port> <file-in-port> 
 <file-out-port> 
 <str-port> port-contents <str-in-port> port-index
 <str-out-port>

 ;; Section 3.13: In.
 read read-from-string
 ;; TODO - Defined in top, where we can't export it: read-file

 ;; Section 3.14: Output.
 write emit writeln write-to-string msg post say

 ;; Section 3.15: System.
 app-filename app-args

 ;; Section 3.16: Top level.
 ;; See goo/eval.

 ;; Undocumented stuff.  This was all found by a process of trial and
 ;; error, but it needs to be here.
 match-atom match-empty-list match-unquote match-sublist
 sexpr-signature-parameters
 %pair %next-methods %define-method %prop %prop-unbound-error
 <handler-info>
 $default-handler-info
 <simple-handler-info>
 handler-info-message
 handler-info-arguments
 napp

 ;; Stuff which should be documented.
 need-implementation bound? dlet t+ t= t< t? t*
 describe-condition
 )

;; TODO: TEMPORARY
(export 
  any2?
  all2?)

;; TODO: HYGIENE
(export
  fab-class
  macro-error
  %prop
  )