Sip proposal: Boolean pattern matching expressions

155 views
Skip to first unread message

Johannes Rudolph

unread,
Oct 31, 2012, 5:06:38 AM10/31/12
to scala...@googlegroups.com, Mathias
Hi all,

as suggested a while ago we have finally written up a proposal for
"Boolean pattern matching expressions" which are short boolean
expressions of the form `expr match pattern`. We are now looking for
feedback. Please see this document for the details:

https://docs.google.com/document/d/1onPrzSqyDpHScc9PS_hpxJwa3FlPtthxw-bAuuEe8uA/edit#

The previous discussion on the mailing list:

https://groups.google.com/d/topic/scala-debate/JdJx03POwyg/discussion


Please comment!

--
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net

Eugene Burmako

unread,
Oct 31, 2012, 5:13:20 AM10/31/12
to scala...@googlegroups.com, Mathias, johannes...@googlemail.com
Added a comment to the SIP.

nafg

unread,
Nov 1, 2012, 5:29:50 AM11/1/12
to scala...@googlegroups.com, Mathias, johannes...@googlemail.com
At the end of the day, what's the advantage of new syntax, over "matches"?

Incidentally, isn't match a special case of |> ? After all, PartialFunction extends Function1. Match essentially takes an argument on the left and a PartialFunction on the right, and applies the PartialFunction with the argument. Only, it requires it to be a PartialFunction literal, and takes advantage of that fact to perform optimizations.
But couldn't you have a syntax that could take any function, and would optimize partial function literals, and still work on other functions?

Sorry for getting off topic, partially I'm wondering if the above (that is, any hypothetical scenario where the above influences scala in the future in any way) has any impact on your idea.
Reply all
Reply to author
Forward
0 new messages