University of Virginia, Department of Computer Science
CS201J: Engineering Software, Fall 2002

Notes: Tuesday 29 October 2002

Subtyping Arrays

What are the advantages of allowing B[] <= A[] when B <= A?

What are the dangers of allowing B[] <= A[] when B <= A?

Abstract Types in C

How can we get the benefits of data abstraction in a language with user-defined types but no abstract data types?


typedef /*@abstract@*/ struct {
  /*@only@*/ char *name;
  /*@only@*/ char *genome;
} *Species;

extern /*@only@*/ Species Species_new (/*@only@*/ char *p_name, /*@only@*/ char *p_genome) 
   /* EFFECTS: Returns a new Species with name p_name and genome p_genome. */ ;

extern /*@observer@*/ char *Species_getName (Species s) ;
extern /*@observer@*/ char *Species_getGenome (Species s) ;

extern /*@only@*/ char *Species_toString (Species s)
   /* EFFECTS: Returns a string representation of s. */ ;

CS201J University of Virginia
Department of Computer Science
CS 201J: Engineering Software
Sponsored by the
National Science Foundation