The paper patches another hole in MATLAB's default encapsulation by tailoring struct. The built-in version of struct returns the names and values of private member variables. In fact, struct 's default behavior represents a risky situation because clients can use it to gain access to private data. It needs to eliminate this possibility by developing a type-specific version of struct.m. As a bonus, a standard function that returns an object's public structure is broadly useful. The strategy of allowing MATLAB to perform most of the formatting requires a structure of public variables. At that time, public structure generation was coded directly in line and we could not easily make use of it in developer view. Further proliferation of in-line structure-generation code makes class extensions very tedious and error prone. Consolidating structure generation into one function makes a lot of sense. We can even take advantage of the tailored version of fieldnames so that even public names are not directly coded into struct.
struct.m, Page 1 of 2
< Previous page Next page > /docserver/preview/fulltext/books/pc/sbpc001e/SBPC001E_ch7-1.gif /docserver/preview/fulltext/books/pc/sbpc001e/SBPC001E_ch7-2.gif