r/Compilers • • Oct 25 '26

Patterns

I've been making a programming language for a while now, and just came up with this idea for a feature i'm bout to implement. Patterns.

   pattern P {
    N;
    T(int, int);
    S {
        int x;
        int y;
    };
}
struct MS {
    int x;
}
class C {
    C() {}
    int y;
}
MS fits P(self) {
    N if (self->x == 0);
    T(self->x, -self->x) if (self->x < 10);
    S {
        x: self->x;
        y: 0;
    } if (self->x < 20);
    default N;
}
C fits P(self) {
    default N;
}
int main() {
    C c = C();
    c.y = 0;
    MS ms = {19};
    match (c) {
        P.N => `qout("Worked");
        default => `qout("Failed");
    }
    match (ms) {
        P.S {x, y} => `qout("Worked");
        default => `qout("Failed");
    }
    return 0;
} 

Basically, making user types have the ability to have custom behavior + extraction in match stmts, beyond just enums & integer types

8 Upvotes

33 comments sorted by

View all comments

Show parent comment

1

u/ApprehensivePipe1584 23d ago

So you didn't code it. I'm assuming it's all AI generated considering it's called AILang. Which implies it's... AI. Sorry you don't like the syntax because... you have complaints against all syntactical styles. That's your opinion. My lang's C style. You don't like C style. Not once have you actually talked about my idea or given a single reason on why it's bad or negative, you have exclusively complained about my syntax in general being c style, which i did not ask your opinion about, and things it literally doesn't do or whatever it is designed to make you not do. In your above example you needed to manually call fits. Which you don't need to do for this. That's the whole purpose. To destructure and call fits for you.

1

u/Far-Championship-883 22d ago

When your done with your post doctoral dissertation on why c is a superior post modern deconstruction and you need a language with high visibility and easy reading, maybe you'll figure it out, and it isn't my language i just use it. AiLang per the author stands for Artificial Intelligence Programming Language. A programming language optimized and designed for AI and human pair programming.

1

u/ApprehensivePipe1584 22d ago

So do you even have your own language? Also, resorting to insults and sarcasm when you start losing a argument just makes you lose harder. Did i ever say C is a superior post modern deconstruction or whatever? No, I posted syntax, you talked about something non topical and dumped hundreds of lines of AILang for no reason because you wanted to sing your song. You don't like any common style of programming languages. OK. Probably don't post on a thread about a specific syntactical feature to complain about the general syntactical style of a language. That's not the question that was asked.

1

u/ApprehensivePipe1584 22d ago

Opinions are free to have, we live in a free country, but it's unhelpful to just dunk on unrelated syntax for no inherant reason and no given reason because you don't like C style or modern style or whatever. If you have a complaint with general syntax, at least give a reason instead of cryptically posting the equivelent of just saying "bad" for no reason. But that's still unrelated to the main post.