about the "xpr" module

crux-00020: $SRC/xpr/README.xpr

* "xpr": Polymorphic expression values

  The "xpr" module provides polymorophic
  expression values.

  It will take several revisions to lay out the 
  full xpr functionality.

  For now, xpr provides only type-tagged numbers and nil.

  Each xpr number is either an int or a float.


* The "xpr" interface

  #include "strt/strt.h"
  #include "xpr/xpr.h"

  struct xpr_ref v = {0,};

  void xpr_load_nil (struct xpr_ref * r);
  void xpr_load_int (struct xpr_ref * r, int v);
  void xpr_load_float (struct xpr_ref * r, int v);
    Change the value of an xpr_ref.

  enum xpr_type xpr_type (struct xpr_ref const * r);
    Returns xpr_is_nil, xpr_is_int or xpr_is_float.

  void xpr_check (struct xpr_ref const * r, enum xpr_type type);
    Panic if the value in *r is not of the indicated type.

  int xpr_read_int (struct xpr_read const * r);
  float xpr_read_float (struct xpr_read const * r);
    Return the int or float in r (respectively).  
    Panic if r is not of the anticipated type.

  void xpr_fmt (strt s, struct xpr_ref const * r);
    Convert the value in r to a string.



/*

    This file is part of Crux.

    Crux is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Crux is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Crux.  If not, see <http://www.gnu.org/licenses/>.

*/