DEV Community

Ethan Onstott
Ethan Onstott

Posted on

StormScript: What's New and What's Better

Intro

On Sunday I made a post explaining what StormScript was and why I believed it was important. Reception was mostly positive with people pointing out things they didn't like with the syntax. I changed two of them. I also changed the Repository so that it is easier to figure out where everything is. Additionally, I added class methods.

Syntax Changes

end;

Both people who commented on my post talked about how they didn't like the end; at the end of each code block. I agreed and had actually been thinking about changing this for a while.

Before:

do {
    int x: 3;
    int y: 4:

    if x is y {
         printl x, " is equal to ", y;
    }else{
        printl x, " is not equal to ", y;
    }end;
}end;

After:

do {
    int x: 3;
    int y: 4:

    if x is y {
         printl x, " is equal to ", y;
    }else{
        printl x, " is not equal to ", y;
    }
}

Function Arguments

The way function arguments were declared was a nightmare. Originally I thought it was ok, but now I realize that it takes up too much unnecessary space.

Before:

@args: int x;
func foo {
    printl x;
}

do{
    foo => x: 3;
}

After:

func foo => int x {
    printl x;
}

do{
    foo => x: 3;
}

Class Methods

Class methods are declared the same as normal functions, but inside of a type scope.

type person {
    int age;
    str name;

    func birthday {
        age+: 1;
    }
}

do {
    person p;
    p|age: 22;
    p|name: "Joe";

    printl p|name, " is ", p|age, " years old!";

    p|birthday;

    printl "It's ", p|name, "'s birthday. ", p|name, " is ", p|age, " years old!";
}

I think that the feedback I received is valuable and will make StormScript better. Please keep sending me suggestions.

Of course check out the repository and be sure to contribute or open a feature request if you would like to see anything added.

Top comments (0)