How do these specs look?
Zavexeon (1041)

Hiya. So, I'm creating my own programming language, Zwei, and I've written a sample spec file for how it's going to look. Before I start making the compiler, I want to make sure that the language is appealing to others. I have a few examples of what the syntax will look like below. I appreciate feedback.

Zwei Specs

#variable declaration; 

my_int = 1232;
my_bool = true; #can be false or null, as well
my_str = 'sample_string'; #double quotes work as well
my_ary = [item1, item2, item3];
my_hash = [item1 => val1, item1 => val2]

#declaring and calling a function

func func_name {
    #function without parameters

func func_name: var1, var2 {
    #function with parameters 

func_name; #calling function without params 
func_name: var1, var2; #calling function with params
func_name(var1, var2) #alternate method of calling func with params


func greet: name {
    io.out: "Hello, #{name}!" #or io.out: "Hello, " + name + "!";

greet: "Bly"; #or greet("Bly");

#control flow 

#if, else, elsif statement 
if: true_statement {                   #if(true_statement) works

} elsif: true_statement {              #elsif(true_statement) works

} else {


weather = 'snowy';

if: weather == 'sunny' {
    io.out('It's sunny outside!'); #remember, this can also be written io.out: 'sample text';
} elsif: weather == 'rainy' {
    io.out('It's rainy.');
} elsif: weather == 'snowy' {
    io.out('It's snowy.');
} else {
    io.out('I'm not sure about the weather.');

#case statement 
case: argument { #case(argument) works
    when: statement { #when(statement) works

    else {


age = 16; 

case: age {
    when: age < 13 {
        io.out("I'm still a little kid!");
    when: age >= 13 {
        io.out("I'm a teenager!");
    when: age > 19 {
        io.out("I'm older than a teenager!");
    else {
        io.out("I'm not sure of the age.");


#while loop
while: true_statement { #while(true_statement) works
    #repeated action

#while loop with break

while: true_statement {
    #repeated action
    #break should be the last line
    breakif: true_statement; #breaks the loop it is held within, breakif(true_statement) works 

#for loops 
for: my_array |obj| { #for(array) |obj| works
    #manipulate obj here 

for: my_hash |key, val| { #for(hash) |key, val|
    #manipulate key and val
#the io object you keep seeing is used to manipulate the console 
io.out(); #outputs an object such as a string, integer, etc; #takes string input (takes one optional argument to try to automatically convert the string input into the object specified, such as an integer, boolean, etc).

I did notice there are some inconsistencies with the io.out function in my specs Functions can be written like this io.out(args) or like this io.out: args.

6 months later

Don't worry this isn't dead, I've refactored some of the syntax slightly, though.

You are viewing a single comment. View All
Answered by vedprad1 (864) [earned 5 cycles]
View Answer
theangryepicbanana (1636)

Also, you should figure out how all of this is going to work internally (unless the language isn't self-hosted)