Jean-Christophe Deschamps wrote: >> Wouldn't it make more sense for "i in 1..5" to expand to "i >= 1 and i >> <= 5"? >> >> Then it would also work for ordered types that aren't ordinal, such as >> rationals >> and strings and blobs and dates etc, and it would work for very large >> ranges, >> since there's no conceptual need to generate all the individual values. >> >> Of course, you'd want to support all 4 variants: 1..5, 1..^5, 1^..5, >> 1^..^5, >> where a ^ means exclude that endpoint and its absence means include. >> >> This is more flexible than SQL's BETWEEN, which I believe only covers >> one of >> those 4 options. > > That's getting into generic interval support. I find this interesting > even if its really much more ambitious than my simple-minded (and > highly optional) initial need/question. > > I might dig further in this direction someday. Good point. > > Thanks Darren.
Getting into, yes. Generally speaking, any time someone is talking about a range in terms of 2 endpoint values, there are 2 distinct things they want: 1. Test if a value is between those 2 endpoints, in which case we have an interval, and the endpoints can be any ordered type. Alternate ways to spell that generally is a pair of binary order-comparison tests. Or you support having your interval as a value in and of itself, but that would be overkill in a system that doesn't already support collection-typed values. That is, I would not recommend SQLite goes to support actual interval/range types, but supporting the .. etc as simply a shorthand syntax for existing comparison ops it already supports, I would say is reasonable to support, essentially an expansion of BETWEEN. 2. Generate a list of values, in which case you need an ordinal type, or a closure to explicitly generate the next list element from a prior one. Such as how one may generically define a "sequence generator". FYI, my Muldis D language for RDBMSs, and Perl 6, as well as other languages, have actual interval types, so you can say "foo in bar" if you want. -- Darren Duncan _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

