-
Notifications
You must be signed in to change notification settings - Fork 0
Home
John Wilkes edited this page Oct 21, 2020
·
6 revisions
This programming language is currently in development. I'm calling the language WIP (Work In Progress) until I think of a better name.
Syntax highlighting extensions are available for these editors:
Below is an example of compiling a simple WIP function and integrating it into a C++ program:
Create a file named fact.wip
.
Then type in the following code:
fun fact(n i32) i32
{
if n <= 1
{
1
}
else
{
n * fact(n - 1)
}
}
Compile this file:
wip fact.wip
This will produce an object file named fact.o
.
Now create a C++ header file for fact.wip
:
wip fact.wip --emit c-header
This will produce a file named fact.h
.
Next, create a C++ file named main.cpp
and type in the following code:
#include <iostream>
#include "fact.h"
int main()
{
for (int i = 0; i < 5; ++i)
{
std::cout << "fact(" << i << "): " << fact(i) << "\n";
}
return 0;
}
Now compile main.cpp
and link it with fact.o
:
clang++ main.cpp fact.o -o fact
This will produce an executable named fact
that will produce the following output:
fact(0): 1
fact(1): 1
fact(2): 2
fact(3): 6
fact(4): 24