Settling out the syntax a bit...
Comments will begin with '#', or be surrounded by '#*' and '*#' for blocks. There will 7 data types: numbers, symbols, strings, vectors, sets, patterns, and literals. These are self explanatory with the exception or the pattern and literal types. A pattern is an expression beginning with '<' and ending with '>' with the operators '+', '-', '*', and '/', a '.' for wildcards, and ',' for concatenation. They're like regular expressions:
Code: Select all
< x , "text" > # match the value of x followed by the string "text"
< x / y , "text" > # match x or y followed by text
< 2 * x , "text" > # match x 2 times followed by text
< 2 + 2 * x, "text" > # match x 2-4 times followed by text
< 4 - 1 * x, "text" > # match x 3-4 times followed by text
< 1 - . * x , "text" > # match x zero or one times followed by text
< 1 + . * x , "text" > # match x one or more times followed by text
< 0 + . * x , "text" > # match x zero or more times followed by text
< (x+8) > # match the value of the expression x + 8
< < x , y > / z > # match x followed by y or z
Patterns are particularly used in function declarations. When you pipe a stream to a function with a pattern, the function will be executed with an argument for a set representing a directed acyclic graph for the input stream based on the pattern. In other words, the language will be really damn good at parsing things quickly and easily. Including itself.
The second thing, literals, are used to declare things 'literally'. eg. if you defined 'x' as '1+1', this would normally be evaluated and 'x' would be set to '2'. With literals, you can tell the compiler, 'no, go screw yourself, I said 1+1'. It's particularly used for declaring macros like:
Code: Select all
if: `('
then: `)?:{'
end: `}'
let:;
be: `:';
which turns
into
Code: Select all
let x be 5;
if x = 5 then
print "hi";
end
It's like C macro's, but more powerful and integrated into the language itself. Below is an example of the current syntax I have in mind:
Code: Select all
#* Main entry point function (fake) *#
main: argc argv
{
s: "Hello World!\n";
x, y: 5, 6;
(x = 5)?
print s;
# This is a 'do' block piping "Hello World!" to magic.
:
{
s >> magic;
}
# This is an 'on' statement for receiving signals
!error
print "Error: Invalid input stream.\n";
# Run a program...literally...
$ `cc -o example example.c'
}
#* This is a magic pattern function! *#
magic:<"Worl">
{
print "It's magic!";
}
You can probably tell from the syntax that what I'm going for is a very meta pure-functional language with no keywords; letting the user define their own macros to deal with that.