In particular, it hides the fact that a directory is not just a collection of files and directories but has several interesting attributes. To model directories in a more faithful manner, we must introduce a structure that collects all relevant properties of a directory. Translate the file system in figure into a Scheme representation according to model 2. Develop the function how-many , which consumes a dir according to model 2 and produces the number of files in the dir tree. The second data definition refined the first one with the introduction of attributes for directories.
Files also have attributes.
To model those, we proceed just as above. For now, we think of the content field of a file as set to empty . Later, we will discuss how to get access to the data in a file. In contrast, the data definitions for dir s and its list of subdirectories still refer to each other and must therefore be introduced together. With two structure definitions and four data definitions, it is, however, far more complicated than the first model.