Jamie Balfour

Welcome to my personal website.

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

Strong-typing in parameters

Strong-typing in parameters

The ZPE/YASS compiler has featured support for typing of parameters for a long time, except it doesn't do anything. One could write something like the example below:

YASS
function test(number $s) {
  print($s)
}

test("Hello world")

And yet nothing will happen when it is given a string value instead of a number value. This is because, although it compiles correctly and is a well-formed ZPE expression, ZPE's runtime doesn't actually know what to do with it. 

Looking back, the way in which ZPE's function calls are made by placing parameters in an ordered set has barely changed and has stayed about the same since ZPE 1.3 when functions were properly introduced. 

ZPE also doesn't support return types. But it will very soon and the syntax has been decided (and included) already:

YASS
function test(number $s) : number {
  return $s + 5
}

Since the original method of generating parameters has been in ZPE and barely changed since 2015, it will be a rather big job to update this but it'll be worth it in the continuing move to making ZPE and YASS strongly typed. However, from ZPE 1.10.8 onwards, it will be possible to write programs that use strongly typed parameters and provide return types, they just will not do anything.

Posted by jamiebalfour04 in General
Comments
Powered by DASH 2.0