Re: [stack] sweetening concatenative syntax

John Nowak <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Mar 6, 2008, at 12:52 PM, William Tanksley, Jr wrote:

> John Nowak <[email protected]> wrote:
>
>> f map = []
>>         [x xs -> x f i xs f map cons]
>>       unlist
>>
>> At the very least, it seems that there's a strong argument for
>> offering lambda expressions and a locals syntax.
>
> Of course, what you typed there is just ambiguous, or possibly
> requires phenominal lookahead (to see if one of the alternatives
> includes a "->" token).

Indeed. There's no way I'd implement it with that syntax, Scheme  
programmer and hater of parsing that I am. The actual syntax I have  
now doesn't require lookahead.

> But in no case does this functionality REQUIRE
> lambdas or locals; why should it? All you're doing is patternmatching.

I'm actively trying to avoid defining the language in terms of pattern  
matching. Here, 'unlist' is just a normal function. But yes, of course  
it doesn't require locals. You could do this as well:

    map = swap
          []
          [rot dup 2keep swap map cons]
        unlist

Anyway, saying that "all your doing is pattern matching" gets more  
complicated when types are involved. For example, when I eventually  
introduce GADTs, sum deconstructors like 'unlist' will need to  
introduce equality constraints. It also isn't clear how a macro could  
be able to inform you if you've not covered all of the possible cases  
when matching. Therefore, any sort of general pattern matching  
facility would need to be implemented into the language proper, and  
ideally I'd like to avoid that as it complicates things.

- John
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.