Hacker News new | past | comments | ask | show | jobs | submit login

How does that differ from a parser combinator library beyond that it's baked into the language? It took a few decades for other languages to catch up, but patterns being first-class objects that can be combined in various ways isn't that unusual. For example, in Lua with LPeg those examples would be:

    full_name = first_name * last_name
    old_school_name = last_name * P', ' * first_name
    any_name = full_name + old_school_name

    (* is sequence, + is or, P is a function that converts a string to a pattern)



While I don't remember enough Snobol to say, in Icon every expression may participate in the pattern-matching search process. For example, `a < b` doesn't produce a boolean value, it either fails (cutting off the current branch of the search) or succeeds (producing b's value as its value, so you can write `a < b < c` with the conventional meaning without any special handling of that form of comparison).

That's the kind of way that patterns are more deeply baked into these languages.


It is similar, but in Snobol, it is a core language feature.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: