Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

ZPE 1.12.7 changes to libraries

One of the significant updates coming to ZPE 1.12.7 is a major change to how ZPE handles library imports. This post is designed to outline this change so I can reference it from the changelog and GitHub commit. 

Before this version, ZPE would read in library imports from a yex file in the libraries folder. This hasn't changed. The library files themselves need not be recompiled. However, the way they are imported has changed. In the older version of ZPE, a library was imported as a variable with all the structures and classes being defined within them:

import stdLib
print($stdLib->bubble_sort([2, 7, 1, 6]))

In ZPE 1.12.7, this changes. Now, instead of adding the bubble_sort function to the $stdLib object, the bubble_sort is put into the top level of the runtime (i.e. added to the global function), so instead you would call bubble_sort:

import stdLib
print(bubble_sort([2, 7, 1, 6]))

ZPE 1.12.7 also allows doing this in the old manner by using the new import as syntax:

import stdLib as stdLib
lib = new stdLib()
print(lib->bubble_sort([2, 7, 1, 6]))

This new change will make some difference to the way in which libraries are used and will improve ZPE performance and memory footprints.

Comments
Powered by DASH 2.0