On Tue, Oct 11, 2011 at 4:25 PM, Stephen Wrobleski <st...@localtoast.org>wrote:

> On Mon, Oct 10, 2011 at 09:24:09PM -0400, David Nolen wrote:
> > I'm not following. Getting accurate information about what failed to
> match
> > needs to be integrated. Given that match makes no restrictions on types
> > there's not much we can do except communicate where we were when the
> match
> > failed via an exception.
>
> Sorry, I was unclear. I was trying to say that having two versions,
> match-debug that throws exceptions, and match-normal that returns nil, is
> redundant - default behavior is easily set with an :else clause. Changing
> the behavior for something marked '-debug' seems like a bad idea as well.
>
> I personally think throwing exceptions is the Right Thing. When adding
> clauses incrementally, I'd rather get a direct error message for unexpected
> values. Exhaustive clauses are a good thing, and :else nil is a simple
> idiom for the 'other behavior'.
>

It's starting to look easier and less complex to stick with the current
behavior. I'll +1 this.


> > Ambrose had some arguments for keeping match and match-1 separate. At the
> > moment I don't see any real issues except that overloading match to
> handle
> > two different cases seems like we're making things slightly more complex.
>
> (Where are these arguments? I thought I remember a wiki with design notes,
> but can't seem to find it). I don't see how it's two different cases.
> Having match take a vector of expressions with 'pattern rows' seems like an
> unnecessarily visible optimization.
>
>
>
My concerns were we should tread carefully to avoid unexpected behavior.

Say we unify the behaviors of match-1 and match.

(match "asdf"  ;; <- looks like a "match-1"
           "no" 1
           "asdf" 2)

(match ["asdf"]   ;; <- looks like a "match"
           ["no"] 1
           ["asdf"] 2)

The second example _looks_ like it's matching a _vector_, but it's actually
matching
a pattern row. There is an important difference when using guards, for
example.

(match ["asdf"]
           (["asdf"] :when (fn [a] ..))  1)   ;; <- illegal, cannot wrap
pattern row in list

If we can resolve this, it would be great!

Thanks,
Ambrose

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to