On 03/21/2012 09:07 PM, Daniel Carrera wrote: > Hello, > > Is it possible to create a new range operator ':' such that: > > a:b is the same as a..b (this is the easy part) > > a:b:c is a range from 'a' to 'b' by steps of 'c'. For example, 2:15:3 > == 2,5,8,11,14
That can be done by giving the new infix:<:> operator list associativity (niecza already supports this) > :b is the same as 0..b create a new prefix operator... except that that prefix : is already taken for constructing pairs > a: is the same as a..Inf create a postfix:<:> operator... except that postfix : is already taken as invocant marker > ::c is the same as 0:Inf:c create a prefix:<::> operator. Except that this collides with existing syntax... > : is the same as 0..Inf create a term:<:>. There are hooks for all of that, but it requires you to come up with a new syntax that doesn't collide heads-on with lots of existing grammar rules. Cheers, Moritz