-
Notifications
You must be signed in to change notification settings - Fork 0
Examples
kwikius edited this page Sep 7, 2025
·
5 revisions
Great — here’s a draft Examples.md you can drop into your wiki alongside Home.md and Units-and-Quantities-Principles.md. I’ve kept the style consistent with the rest.
This page shows example usage of gzScript for units and quantities.
length = 25.4:mm:; // 25.4 mm
distance = 1:m:; // 1 metre
// automatic SI conversion
sum = length + distance; // = 1.0254:m:
d = 100:m:;
t = 9.58:s:;
v = d / t; // = 10.44:m/s:;
w = 2:m:;
h = 3:m:;
area = w * h; // = 6:m^2:;
h:height: = 1.75:m:;
w:width: = 0.30:m:;
// ok: assign from anonymous length
h = 2:m:;
// error: width cannot be assigned from height
w = h; // compile error
phi = 180:deg:;
theta = 3.14159:rad:;
// explicit conversion deg → rad
phi_r = phi:rad:;
// ok: radians interchangeable with dimensionless
x = sin(theta);
a = 2:ft:;
b = 1:m:;
// result is SI
c = a + b; // 1.6096:m:
force = 10:N:; // newton
area = 2:m^2:;
pressure = force / area; // 5:Pa:
This page is a living draft. More examples will be added as gzScript features evolve.
Would you like me to also prepare a Design-Notes.md wiki page where you can log open questions (like integer literal promotion, or how refinements interact with comparisons)? That might help keep track of the evolving semantics.