Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiscreteDomains.characters() #860

Open
gissuebot opened this issue Oct 31, 2014 · 10 comments
Open

DiscreteDomains.characters() #860

gissuebot opened this issue Oct 31, 2014 · 10 comments

Comments

@gissuebot
Copy link

Original issue created by wasserman.louis on 2012-01-10 at 04:29 PM


I'm curious if anyone else would be interested in e.g. Ranges.closed('a', 'z') and the like.

@gissuebot
Copy link
Author

Original comment posted by kevinb@google.com on 2012-01-11 at 12:15 AM


Nothing wrong with it; not sure if it's needed.


Status: Triaged
Labels: Type-Enhancement

@gissuebot
Copy link
Author

Original comment posted by wasserman.louis on 2012-01-11 at 01:33 AM


For reference, the question was inspired by http://stackoverflow.com/questions/8710719/generating-an-alphabetic-sequence-in-java, perhaps coupled with Sets.cartesianProduct.

@gissuebot
Copy link
Author

Original comment posted by wasserman.louis on 2012-02-16 at 06:26 PM


(No comment entered for this change.)


Labels: Package-Collect

@gissuebot
Copy link
Author

Original comment posted by fry@google.com on 2012-02-16 at 07:17 PM


(No comment entered for this change.)


Status: Acknowledged

@gissuebot
Copy link
Author

Original comment posted by kevinb@google.com on 2012-05-30 at 07:43 PM


(No comment entered for this change.)


Labels: -Type-Enhancement, Type-Addition

@gissuebot
Copy link
Author

Original comment posted by kevinb@google.com on 2012-06-22 at 06:16 PM


(No comment entered for this change.)


Status: Research

@gissuebot
Copy link
Author

Original comment posted by plasma147 on 2012-08-17 at 09:54 PM


Without knowing about this request, I raised a similar question about this on stackoverflow:
http://stackoverflow.com/questions/12006964/does-guava-provide-any-support-for-defining-ranges-of-characters/12009740#12009740

I think it would be nice to be able to declaratively declare a set of characters to iterate over.

It would also be nice to be able to declare discrete domains over arbitrary sets - all vowels, [red,blue,green], all strings that are less than 5 characters.. etc - without the limitation of having to cover all instances of a specific type.

@gissuebot
Copy link
Author

Original comment posted by wasserman.louis on 2012-08-17 at 10:07 PM


I think it's sane to keep the "all instances of a type" restriction on DiscreteDomains, if only because it keeps the various behaviors well-defined -- you can take an arbitrary Range<Integer> and turn it into a Set, but the behavior if you have a DiscreteDomain for only positive integers is...less well-defined.

If you want some other behavior, go ahead and roll your own implementation for whatever it is you want, but I really, really like the approach to Range that keeps all the semantics very well-defined and obvious.

That said, I'm still +1 on DiscreteDomains.characters() specifically...and possibly BigInteger, while we're at it? Eh. I don't think there's any serious potential for abuse, and I think the API bloat issues aren't too big a deal here -- DiscreteDomains isn't a particularly bloated class.

@gissuebot
Copy link
Author

Original comment posted by kevinb@google.com on 2012-08-18 at 06:30 AM


Agreed on all points with Louis.

The limitations documented on DiscreteDomain are extremely intentional. Ranges don't have holes; that's what makes them ranges. Plus to support the kind of "holey" ranges you ask for we'd need several additional methods on DiscreteDomain and even then there are some really nasty edge cases to deal with. It's not worth it.

But a discrete domain for characters, sure. It will raise the question of whether there should be some specific glue for converting to/from a CharMatcher; I don't see that working out neatly but maybe. bigIntegers also yes: I think it's even there already but just not tested and so not public.


Status: Accepted

@ronshapiro
Copy link
Contributor

@lowasser shall we bring this to API review?

@ronshapiro ronshapiro assigned ronshapiro and lowasser and unassigned ronshapiro Oct 4, 2017
@raghsriniv raghsriniv added the P3 label Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants