between and among: worth Phobosization?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Dec 17 10:06:27 PST 2013


On 12/16/13 5:02 PM, Chris Cain wrote:
> On Monday, 16 December 2013 at 20:38:52 UTC, Andrei Alexandrescu wrote:
>> bool between(T, U1, U2)(T v, U1 lo, U2 hi)
>> {
>>     return v >= lo && v <= hi;
>> }
>
> I realize this is, at this point, being retracted. But it would open up
> some interesting ideas. It seems a lot like iota, but it could look
> pretty cool for some purposes. Consider an alternative API where you
> could do things like this:
>
> ---
> if(x in between(2, 7)) {
>     //...
> }
> ---

That's problematic. "Between" is a preposition. Naming a function as a 
preposition is fine as long as a verb is implied (e.g. "a in b" really 
means "a _is_ in b", or "a.between(b, c)" really means "a _is_ between b 
and c" etc).

Reifying "between" to the status of object is weird. One constructs a 
"between" object and then what are its primitives? How can one even talk 
about it? "Yeah I have a between here and I copy it to another between"...

"x in between(2, 7)" is cute but just that - it's a lucky strike that 
relies on word ordering in a particular phrase and is unlikely to work 
in many other places.


Andrei



More information about the Digitalmars-d mailing list