I think that for formatters we should use followih category:

)abbrev category FORMCAT OutputFormaterCategory
OutputFormaterCategory : Category == with
    convert :  (OutputForm, Integer) -> %
      ++ convert(o, step) changes o in standard output format to
      ++ given format and also adds the given step number. 
    display : % -> Void
      ++ display(t) outputs the formatted code

-------------

This captures current usage for system output.  As I wrote,
current formatters behave mostly like packages.  The
definition above means that formatter is a domain,
Why?  Having separate 'convert' and 'display' gives room
for setting options and for example convertion to strings.
Also, this gives better oportunity to use some smart data
structure.

Also, we should get rid of '$Lisp' calls used to traverse
Output form.  My first shot is the following package.
As you can see test are done via Lisp calls.  But once
formatters are converted to use this package we can
replace traversal function by different ones.  In the
future I would prefer to have more abstract operators
instead of using Output form as operator.  We will also
need more tests for specific operators.  But already
this version should move us in right direction.

--------

)abbrev package OFTOOL OutputFormTools
OutputFormTools : with
    atom? : OutputForm -> Boolean
      ++ atom?(f) checks if form f is atomic, false means composite
    integer? : OutputForm -> Boolean
      ++ integer?(f) checks if f is an integer, this implies atom?(f)
    integer : OutputForm -> Integer
      ++ integer(f) gives integer corresponding to f.  Valid only
      ++ when integer?(f) is true
    symbol? : OutputForm -> Boolean
      ++ symbol?(f) checks if f is a symbol, this implies atom?(f)
    symbol : OutputForm -> Symbol
      ++ symbol(f) gives symbol corresponding to f.  Valid only
      ++ when symbol?(f) is true
    string? : OutputForm -> Boolean
      ++ string?(f) checks if f is a string, this implies atom?(f)
    string : OutputForm -> String
      ++ string(f) gives string corresponding to f.  Valid only
      ++ when string?(f) is true
    operator : OutputForm -> OutputForm
      ++ operator(f) gives operator (head) of form f.  Valid only
      ++ when atom?(f) is false
    arguments : OutputForm -> List(OutputForm)
      ++ arguments(f) gives arguments of form f.  Valid only
      ++ when atom?(f) is false
  == add

    atom?(x) == ATOM(x)$Lisp

    integer?(x) == INTEGERP(x)$Lisp

    integer(x) == x pretend Integer

    symbol?(x) == SYMBOLP(x)$Lisp

    symbol(x) == x pretend Symbol

    string?(x) == STRINGP(x)$Lisp

    string(x) == x pretend String

    operator(x) == first(x pretend List(OutputForm))

    arguments(x) == rest(x pretend List(OutputForm))

--------------------
-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to