  
  [1X8 [33X[0;0YRecords[133X[101X
  
  
  [1X8.1 [33X[0;0YFunctions for records[133X[101X
  
  [1X8.1-1 AssignGlobals[101X
  
  [33X[1;0Y[29X[2XAssignGlobals[102X( [3Xrec[103X ) [32X function[133X
  
  [33X[0;0YThis function has been transferred from package [5XRCWA[105X.[133X
  
  [33X[0;0YIt  assigns  the  record components of [3Xrec[103X to global variables with the same
  names.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr := rec( a := 1, b := 2, c := 3 );;                                      [127X[104X
    [4X[25Xgap>[125X [27XAssignGlobals( r );[127X[104X
    [4X[28XThe following global variables have been assigned:[128X[104X
    [4X[28X[ "a", "b", "c" ][128X[104X
    [4X[25Xgap>[125X [27X[a,b,c];[127X[104X
    [4X[28X[ 1, 2, 3 ][128X[104X
  [4X[32X[104X
  
  
  [1X8.2 [33X[0;0YOption records for functions[133X[101X
  
  [1X8.2-1 OptionRecordWithDefaults[101X
  
  [33X[1;0Y[29X[2XOptionRecordWithDefaults[102X( [3Xdefaults[103X, [3Xuseroptions[103X ) [32X function[133X
  
  [33X[0;0YThis  functions has been transferred by Chris Jefferson from other packages.
  It  simplifies  the  handling  of  records which are intended to be used for
  expressing  configuration options. [3Xdefaults[103X represents the "default record",
  and [3Xuseroptions[103X lets the user give new values for values in [3Xdefaults[103X.[133X
  
  [33X[0;0YThe  function returns a record with the same component names as [3Xdefaults[103X and
  which  has  the same values as [3Xdefaults[103X, except for those component names in
  [3Xuseroptions[103X,  where  the values in [3Xuseroptions[103X are used instead. An error is
  given  if  [3Xuseroptions[103X  contains  any  component  names  not in [3Xdefaults[103X. If
  [3Xuseroptions[103X  is  an  empty  list  it  is  treated as an empty record, and if
  [3Xuseroptions[103X  is  a list of length [22X1[122X containing a record, this record is used
  as [3Xuseroptions[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xdefaults := rec( a := 1, b := 2, c := 3 );;[127X[104X
    [4X[25Xgap>[125X [27XOptionRecordWithDefaults( defaults, rec( a := 6) );[127X[104X
    [4X[28Xrec( a := 6, b := 2, c := 3 )[128X[104X
    [4X[25Xgap>[125X [27XOptionRecordWithDefaults( defaults, rec( b := 7, c := 8 ) );[127X[104X
    [4X[28Xrec( a := 1, b := 7, c := 8 )[128X[104X
    [4X[25Xgap>[125X [27XOptionRecordWithDefaults( defaults, [ ] );[127X[104X
    [4X[28Xrec( a := 1, b := 2, c := 3 )[128X[104X
    [4X[25Xgap>[125X [27XOptionRecordWithDefaults( defaults, [ rec( c := 8 ) ] );[127X[104X
    [4X[28Xrec( a := 1, b := 2, c := 8 )[128X[104X
    [4X[25Xgap>[125X [27XOptionRecordWithDefaults( defaults, rec( d := 9 ) );[127X[104X
    [4X[28XError, Unknown option: d[128X[104X
    [4X[25Xgap>[125X [27XOptionRecordWithDefaults( defaults, [ rec( b := 7 ), rec( c := 8 ) ] );[127X[104X
    [4X[28XError, Too many arguments for function[128X[104X
    [4X[25Xgap>[125X [27XOptionRecordWithDefaults( defaults, [6,7,8] );[127X[104X
    [4X[28XError, Too many arguments for function[128X[104X
  [4X[32X[104X
  
  [33X[0;0YThis function is designed to support functions with optional arguments given
  as a variable record, of the form [10Xfunction(x,y,options...)[110X.[133X
  
  [33X[0;0YIn  the  following,  very  contrived, example function, [10XPrintDimensions[110X, the
  defaults  are  given  by  the  variable  [10Xorder[110X which takes values [10Xh[110X, [10Xw[110X and [10Xd[110X
  having  default  values  [22X1[122X,  [22X2[122X  and  [22X3[122X.  If there is a second argument, then
  [10XOptionRecordWithDefaults(  order,  arg[2]  );[110X  is used to change the values.
  These  three  values  then determine the order in which the three dimensions
  are printed using a [10XSortParallel[110X command.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XPrintDimensions := function( arg )[127X[104X
    [4X[25X>[125X [27X   local nargs, dim, order, V, L, len, K, i;[127X[104X
    [4X[25X>[125X [27X   nargs := Length( arg );[127X[104X
    [4X[25X>[125X [27X   dim := [ arg[1]!.height, arg[1]!.width, arg[1]!.depth ];[127X[104X
    [4X[25X>[125X [27X   order := rec( h := 1, w := 2, d := 3 );[127X[104X
    [4X[25X>[125X [27X   V := [ "height", "width", "depth" ];[127X[104X
    [4X[25X>[125X [27X   if ( nargs > 1 ) and IsRecord( arg[2] ) then[127X[104X
    [4X[25X>[125X [27X       order := OptionRecordWithDefaults( order, arg[2] );[127X[104X
    [4X[25X>[125X [27X   fi;[127X[104X
    [4X[25X>[125X [27X   L := [ order!.h, order!.w, order!.d ];[127X[104X
    [4X[25X>[125X [27X   len := Length( L );[127X[104X
    [4X[25X>[125X [27X   K := [ 1..len ];[127X[104X
    [4X[25X>[125X [27X   SortParallel( L, K );[127X[104X
    [4X[25X>[125X [27X   Print( "dimensions: " );[127X[104X
    [4X[25X>[125X [27X   Print( V[K[1]], " = ", dim[K[1]], ", " );[127X[104X
    [4X[25X>[125X [27X   Print( V[K[2]], " = ", dim[K[2]], ", " );[127X[104X
    [4X[25X>[125X [27X   Print( V[K[3]], " = ", dim[K[3]], "\n" );[127X[104X
    [4X[25X>[125X [27Xend;;[127X[104X
  [4X[32X[104X
  
  [33X[0;0YIn  the  example  below  the  first  call  to  [10XPrintDimensions[110X  has just one
  parameter,  [10Xmydim[110X,  so  the  default  order  is  used.  In  the second call,
  alternate  values  for [10Xh[110X, [10Xw[110X and [10Xd[110X are given, causing the width to be printed
  first, and then the depth and height.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xmydim := rec( height := 45, width := 31, depth := 17 ); [127X[104X
    [4X[28Xrec( depth := 17, height := 45, width := 31 )[128X[104X
    [4X[25Xgap>[125X [27XPrintDimensions( mydim );[127X[104X
    [4X[28Xdimensions: height = 45, width = 31, depth = 17[128X[104X
    [4X[25Xgap>[125X [27XPrintDimensions( mydim, rec( h:=3, w:=1, d:=2 ) );[127X[104X
    [4X[28Xdimensions: width = 31, depth = 17, height = 45[128X[104X
  [4X[32X[104X
  
