Yazoo ---> Online Help Docs ---> Yazoo scripting

Classes and Inheritance

Most of the ingredients of a Yazoo script that we've encountered up to this point -- variables, functions, data types -- are standard fare, in one form or another, in bread-and-butter C. In this last section of the chapter we will demonstrate the measure of Yazoo's proficiency in the high cuisines of object-oriented programming. Yazoo was not explicitly intended to be object-oriented. But some of its capabilities look and smell quite a lot like features of the OOP languages. The rundown is: classes are straightforward; encapsulation is disappointing; polymorphism is obvious; and inheritance has some unusual generalizations to functions and the like.

Start with the bad news: encapsulation is one thing that Yazoo is really awful at. By use of the clip() tool we can blind a function to its environment, as we showed in the last section. But the environment can still see---and manipulate---the function and its contents. To hide the innards of a function we would need to remove its members, but by dismembering the function we would obviously ruin it. Any search path that leads to the function can go anywhere within the function; there is no way to selectively hide members only from certain paths.

A poor substitute for encapsulating code is to pseudo-compile a function into bytecode separately from the main script. Using tricks from the next chapter it would be possible to embed this bytecode underneath the skin of the main script. But that is not really encapsulation, since the function's members can still be accessed using the array-index operators `[]'. The best that can be said is that a separate compilation hides the function's source code and thus masks all the names of the members that were defined, so that the function cannot be explored from outside using the step-to-member operator `.', except by blundering about in a very awkward way.


Prev: Search Paths and Fibrils   Next: Classes


Last update: July 28, 2013

Get Yazoo scripting language at SourceForge.net. Fast, secure and Free Open Source software downloads