Skip to content
Snippets Groups Projects
Forked from cmucl / cmucl
Source project has a limited visibility.
  • dtc's avatar
    764ec478
    Implement a specializing CONS class as per issue CONS-TYPE-SPECIFIER:ADD. · 764ec478
    dtc authored
    The new cons-type which maintains the specialised CAR and CDR types:
    
    o Typep recurses, checking the respective car and cdr specialisations;
      two cons-types are type= if both their car and cdr types are type=.
    
    o Subtypep recurses, applying subtypep to the respective car and
      cdr types. If both sub-tests return true then the cons test returns
      true with a win only when both sub-tests win. If either sub-test
      returns false then the cons tests returns false with a win if either
      of sub-tests win.
    
    o Type-intersection is applied to the respective car and cdr types,
      and wins if both win.
    
    o The type-union of two cons-types handles cases for which either the
      respective car or cdr types are type=, in which case type-union is
      applied to the other type. This avoid returning an overly general result.
    
    o Ctype-of a cons object simply returns (cons * *); and does not attempt
      to recurse.
    
    o The compiler recursively checks the specialised type of the cons-type,
      which allows it to also use this type information to derive the result
      type car and cdr. Inline code is currently only generated when
      natively compiling.
    764ec478
    History
    Implement a specializing CONS class as per issue CONS-TYPE-SPECIFIER:ADD.
    dtc authored
    The new cons-type which maintains the specialised CAR and CDR types:
    
    o Typep recurses, checking the respective car and cdr specialisations;
      two cons-types are type= if both their car and cdr types are type=.
    
    o Subtypep recurses, applying subtypep to the respective car and
      cdr types. If both sub-tests return true then the cons test returns
      true with a win only when both sub-tests win. If either sub-test
      returns false then the cons tests returns false with a win if either
      of sub-tests win.
    
    o Type-intersection is applied to the respective car and cdr types,
      and wins if both win.
    
    o The type-union of two cons-types handles cases for which either the
      respective car or cdr types are type=, in which case type-union is
      applied to the other type. This avoid returning an overly general result.
    
    o Ctype-of a cons object simply returns (cons * *); and does not attempt
      to recurse.
    
    o The compiler recursively checks the specialised type of the cons-type,
      which allows it to also use this type information to derive the result
      type car and cdr. Inline code is currently only generated when
      natively compiling.