ABSTRACT
Like always, if we don’t like what the built-in version gives us, we simply tailor the function to suit our purposes. In this particular case, tailoring is not perfect because we can’t prevent clever or devious clients from using
builtin
to tie their code to an object’s private data. A client can bypass all our carefully crafted member functions by using, for example,
shape_struct = builtin(‘struct’, shape)
When a client uses
builtin
in this way, shape_struct
is not an object, but rather a structure. With a structure, the client loses the ability to call member functions, but in return gains the ability
client has a structure, the object is usually forgotten. Unfortunately, there is no way to prevent a client from using builtin
. For this very reason, clients should be told about
builtin
and strongly cautioned against its use. There is no conceivable reason for a client to circumvent the behavior of any type-specific member function by using a call to
builtin
. This decision belongs to a class developer and not a client. Class developers can and often do use
builtin
to coerce MATLAB into doing work for them; however, if class developers are doing their job properly, it is extremely rare for a client to have the same need. This is particularly true with
struct
.