complement to $

Steven Schveighoffer schveiguy at yahoo.com
Fri May 14 19:14:22 PDT 2010


On Fri, 14 May 2010 16:42:28 -0400, Ali Çehreli <acehreli at yahoo.com> wrote:

> Steven Schveighoffer wrote:
>
>  > In regex, ^ matches beginning of the line, $ matches end of the line
>
> So far so good... :)
>
>  > So how does this look:  coll[^..$];
>
> Speaking of regex, [^ sequence starts a set of excluded characters. :)

Yeah, that is a good counter-argument :)

> $ has always bugged me anyway, so how about no character at all:
>
> coll[..n];  // beginning to n
> coll[n..];  // n to end
> coll[..];   // all of it
>
> I like it! :)

Well, for true contiguous ranges such as arrays, you need to have ways of  
adding or subtracting values.  For example:

a[0..$-1];

How does that look with your version?

a[0..-1];

not good.  I think we need something to denote "end" and I would also like  
something to denote "beginning", and I think that can't be empty space.

-Steve


More information about the Digitalmars-d mailing list