0.4.2 release & OO features

There were some errors in the RELEASE-NOTES included with the 0.4.2 release regarding object copying.

In 2 places in the RELEASE-NOTES it states that objects can never be copied. This is not true. Objects can be copied by explicitly cal\ ling the "copy()" method. Otherwise they will be referenced by default.

INCORRECT example
$a = new Class();
$b = $a; # $b holds a reference to object $a
delete $b; # the single object is deleted
$a.method(); # throws an exception because the object was deleted

CORRECT example
$a = new Class();
$b = $a.copy(); # $b is a copy of $a
delete $b; # the copy is deleted
$a.method(); # no exception is thrown

To prohibit an object from being copied, define a "copy()" method in the class, and throw an exception in the "copy()" method.

NOTE: you don't have to define a copy method to support copying in your object - by default the system generates a new object and then c\ opies all members to the new object, except members that are themselves objects are referenced. In this case "copy()" does a shallow co\ py of the members (similar to the object.clone() method in Java). However, unlike Java, if any copy methods exist (in the current class\ or in base classes) they will be executed in the new object, with a reference to the original object passed as the first argument to th\ e "copy()" method.

Also, I forgot to include in the RELEASE-NOTES information about the new parse options, like:
%no-global-vars
%no-subroutine-defs
%no-threads
%no-top-level
%no-class-defs
%no-namespace-defs
%no-external-process
%lock-options
%no-process-control
%no-constant-defs
%no-new
%no-child-restrictions
%require-our
%exec-class

that can be used (if the parse options have not been locked - another new feature in this release) instead of command-line options to control how code is parsed.

thanks
david

Posted by David Nichols 2005-12-09

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks