Thanks all...
I'm not actually complaining that symbols are taken for bind
variables. I think in most common match uses that's very natural.
Your suggested change wouldn't actually help me - this was just a
dummy example; in the actual case for me the symbol starts with an
alpha.
If I *were* going to suggest a naming rule to disambiguate bind
variables from symbols, I'd suggest using a leading _ on bind
variables:
;; plus is a symbol to match, _x, _y are variables
(let [e '(plus 2 3)]
(match [e]
[([plus _x _y] :seq)] (+ _x _y)))
To me, that gives them a "placeholder" feel and plays well with the
use of _. This would break all existing code of course, so I don't
suggest this too seriously. :)
Alex
On Nov 30, 3:29 pm, Steve Miner <[email protected]> wrote:
> On Nov 30, 2011, at 3:04 PM, David Nolen wrote:
>
> > (quote foo) should be interpreted as a literal match. I thought this was
> > addressed by a previous user submitted patch but it doesn't look like
> > that's true.
>
> I wrote a patch that treated quoted keywords as literals so that ':when could
> be used to match a literal :when as opposed to introducing a guard. Sorry, I
> didn't think about the case of literal symbols. I assumed they already
> worked that way. Hmmm, maybe there's a difference between the :seq and
> vector matching. I will take a look tomorrow to see if I can come up with a
> patch.
>
> The complaint about reusing symbols is also my contribution. Maybe match
> bindings should be limited to symbols starting with an alphabetic character.
> I doubt anyone really wants to bind to symbols that look like operators.
> They could be treated as literals for the sake of matching. Any opinions on
> that?
>
> Steve Miner
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en