Two standard classes may also be modified in FeResPost: the ``Float'' class and the ``Array'' class; the operators are modified in such a way that the second operand may be a ``Result'' object. If the second operand is not a Result object, the default version of the operator is called. Table I.7.1 summarizes the modifications in these classes.
Practically, the modification of standard classes is done in ruby file ``modifStdClasses.rb''. Until version 3.2.7 of FeResPost, the modification was done in the compiled library. Now the fact that the modification of standard classes is done with ruby statements allows the user to cancel these modifications, for example by erasing the corresponding lines in the ``FeResPost.rb'' file of the distribution. The file would then look as follows:
if (RUBY_PLATFORM.include?("win")) then require "FeResPost.dll" else require "FeResPost.so" end #require "modifStdClasses" STDOUT.printf("End \"FeResPost\" module initialization.\n") STDOUT.printf("\n\n") STDOUT.flushThe reason why the modification of standard classes is displaced into a ruby source file rather than in the compiled part of the extension is that one tries to maintain the compiled library in line with the COM component. Moreover, it is not very good practice to modify standard classes in a programming language.
The two classes that are modified are ``Float'' and ``Array'' classes. In each case, when an operator is called, the corresponding ``Operator'' method in ``Post'' Module is called. for example, the two following statements are equivalent:
z=x+y z=Post.opAdd(x,y)Actually, this is true only if is an object of the class ``Float'' or ``Array''.
Practically, the modification of standard classes is done in two steps:
class Float alias _FeFesPost_old_opAdd + ... def +(second) if second.class==Result then return Post.opAdd(self,second) else return self._FeFesPost_old_opAdd(second) end end ... end # Float