# Pattern matching, stack comments

## andrew cooke — 2004-04-05 20:50:17

    Hi,

    Are either of these ideas useful?  I've not used Joy (or APL, J, K etc),

    although I did play with Forth a little just under 20 years ago...

    First - maybe you add some kind of support for comments on the stack, so

    that operations that pushed values could attach comments.  Then a stack

    dump might show not just values, but also comments.

    Second - could you add pattern matching to definitions, to make them

    simpler to read?  Then swap might be defined something like:

    swap a b == b a

    I can already see at least two objections to the second point - first that

    it's not clear whether you match atomic values or sub-stacks and second

    that you might lose much of the concatenative flavour of the language (or,

    alternative, that if you're used to programming in a such a style, such

    matching appears redundant).

    Thanks,

    Andrew

    --

    ` __ _ __ ___  ___| |_____   work web site: http://www.ctio.noao.edu/~andrew

     / _` / _/ _ \/ _ \ / / -_)  personal web site: http://www.acooke.org/andrew

     \__,_\__\___/\___/_\_\___|  personal gallery: http://www.acooke.org/pancito