To use this website fully, you first need to accept the use of cookies. By agreeing to the use of cookies you consent to the user of functional cookies. For more information read this page.

Structures in ZPE 1.7.3

05 Mar 2019 at 19:38
Another big change worth noting!

ZPE 1.7.3 now brings a big change to the way in which structures work in ZPE. Originally, objects were extensions to the design of structures but as time went on it actually became structures that were extensions to objects.

Now, the object has become such a major part of YASS that the language itself has become largely object oriented. As direct result, structures have formed a major part of the design with much of the language being developed to take advantage of them. Now, with ZPE 1.7.3, structures differ from objects for the first time.

Structures were always blueprints or templates of objects that were yet to be defined, much like in an E-R diagram and entity is a description of a record that has yet to be implemented. But structure instances always allowed you to add properties like in JavaScript which in my opinion was plain silly.

So:

YASS
structure tester 

  $name = ""
  $dob = "1970-01-01"

end structure

$person = new tester()
print($person->$name)
$person->$test = 10

This was valid in ZPE as it is in JavaScript where a previously undefined property (in this case $test) can be defined at runtime. Not any longer. ZPE 1.7.3 changes this an enforces the structure on the user. Another major update that comes with this is the new class keyword that can be used instead of structure.

There have also been significant changes to the standard library that is now available on ZULE too. This update to the library makes it no longer backward compatible with ZPE version 1.6.x and before but it makes it better for the newer versions.