You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2020/06/04 20:52:52 UTC

[GitHub] [lucenenet] NightOwl888 commented on issue #293: RegexpQuery doesn't maintain any reference to the Regexp

NightOwl888 commented on issue #293:
URL: https://github.com/apache/lucenenet/issues/293#issuecomment-639110200


   As this is Lucene's design, not our own, we don't really have the latitude to make changes of this nature. We have been careful to preserve the accessibility of each class and member to match Lucene and to provide the same amount of extensibility in most cases.
   
   That being said, as you have already discovered the "untouched, original value of the query" is already exposed as a protected `Term` property. I believe it was done this way because in Java it is possible to make "anonymous classes". For example, you could declare a new class inline that subclasses `RegexpQuery` in which the `Term` property would automatically be exposed. In C# you have to hand-roll a subclass, which makes it less convenient, but still exposes the same accessibility. Unfortunately, as the intent of the design is lost when converting code line by line, we can't really be sure of all of the places the Lucene designers intended to use "anonymous classes" that would potentially be suited for a better approach in .NET.
   
   As for a deeper in-depth discussion of the reasoning behind the design, please contact the  [dk.brics.automaton authors](https://www.brics.dk/automaton/) or the [Lucene team](https://lucene.apache.org/core/discussion.html). 
   
   FWIW, the internals of regular expression engines always throw away consumed characters by default and only capture if the regular expression engine supports it, such as with [capturing groups](https://www.regular-expressions.info/refcapture.html). If you are going to argue to support something like this, I would suggest arguing for a standardized capture of some kind rather than a one-off.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org