5 ms·
That's cool! I actually tried something like this myself, but ended up with a less conventional syntax. I'm not really familiar with Forth, but my impression f
by ioddly 10y ago
That's cool! I actually tried something like this myself, but ended up with a less conventional syntax.
I'm not really familiar with Forth, but my impression from writing a little bit of postfix code was that some pattern matching would make e.g. writing a large conditional much easier.
- codr4life 10y agoForth is trivial to learn but takes serious effort to master, like Lisp and C. I'm a humble beginner myself when it comes to Forth. A match operator is a possibility, but too much of that will ruin all that's good about Forth. I already added word scoped variables, and I already feel like I'm balancing near the point of negative return.
- PeCaN 10y agoThat's something I'm working on, actually. I think matching the top stack item(s) fits well into a postfix stack-oriented language. For example: TYPE: Tree | Branch(Tree,Tree) | Leaf ; :: depth Tree -> Int ; : Branch($,$) depth {depth} dip depth + ; : Leaf depth 1 ; $ is extract, so the pattern Branch($,$) pops the top of the stack and pushes the 2 members. Types and type constructors have to start with a capital letter, but I like the : Pattern word definition ; syntax a lot.