b31f2aaaa5869504690d98b5318479e8f16feeab
zc
What if C, but easier?
What is zc?
zc is a headerfile which makes a bunch of macros which mess with the way the C programming language works.
One of the primary advantages of using zc is easier object orientated patterns, without the bloat of C++. (The syntax does need a little getting used to.)
Setup
sudo make install
Usage
There are 2 ways to use zc:
- Inside of C - do
#include <zc.h>and you've now got access to all that zc has to offer. - Using a .zc file and the zc command - you won't be yelled at as much. Type
zc filename.zcto compile.
However, using either will allow you to program in the same way.
Syntax
This section is WIP
Define an entry point:
entry {
}
Create variables:
entry {
Integer x is 5;
}
Print something out:
entry {
Integer x is 5;
print(x);
}
Create a list of something:
entry {
Integer list x is many(Integer, 5);
x[0] is 5;
x[1] is 10;
x[2] is 15;
x[3] is 20;
x[4] is 25;
// Resize the list
resize(x, 10);
}
Create a class, constructor, destructor, and methods:
class(Car, {
String make;
Integer year;
Method(Car, drive, void);
Destructor(Car);
});
method(Car, drive, void) {
// self allows you to access elements inside the class
printf("Car %s from %d goes vroom vroom\n", self->make, self->year);
}
destructor(Car) {
free(self->make);
}
constructor(Car, String make, Integer year) {
return (Car) {
.make = make,
.year = year,
.drive = &__Car_drive,
.destructor_fn = &destroyCar,
};
}
entry {
Car myCar = newCar("Toyota", 1996);
myCar.drive(&myCar);
}
See bank.zc for a full example.
Description
Languages
C
96.4%
Makefile
3.6%