[Issue 9895] Add functional style regex pattern-matching

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 8 10:22:40 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9895



--- Comment #2 from IdanArye <GenericNPC at gmail.com> 2013-04-08 10:22:37 PDT ---
(In reply to comment #1)
> Another way to do this is with the unapply() of Issue 596

Yes, it looks like it is possible to do this with unapply(which should be
opUnapply to be compatible with D's naming conventions). However:

1) In the GitHub pull request, Dmitry Olshansky suggests to combine all
patterns to a single, big pattern, to improve performance. I have no idea how
to do it, but it might be done in the future, and it can't be done with the
switch+opUnapply version.

2) switch in D is a statement, not an expressions - it does not return a value.

3) Scala's unapply for regular expressions does not convert data types. I don't
know if it can be done in D's version - it's too early to tell, seeing that
opUnapply has not been implemented yet.

4) opUnapply is not in D yet - it's still an enhancement suggestion. We don't
know what complications we are gonna have when we try to use it for regular
expressions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list