Ethereal-dev: Re: [Ethereal-dev] a modest proposal (range filtering RFC)

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Ed Warnicke <hagbard@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Dec 2000 00:50:57 -0500 (EST)
> > 1)    Ranges of the form [i:j] (j positve) will be considered to be
> >       [offset:length], as currently.
> >
> > 2)    Ranges of the form [i:-j] will be considered to be
> >       [offset:maxoffset - j].  In otherwords [i:-j]
> >       denotes the range from the offset i to -j length from the end
> >       of the sequence.
> 
> Bit of a user interface nightmare.

Depends very much on the user.  

> 
> Why not var[i-j] for a range and var[i,j] for a offset, length.
> 
> var[i-] and var[i,] should mean the same.
> 
> var[i:j] could remain as it is now, but deprecated.
> 
The problem with the var[i-j] notation is that it will conjure up in 
the minds of everyone who has ever programmed in C, C++, Java, Perl, 
Python, etc the notion of "the i minus j th element", very bad 
asthetically.  The problem is that to the best of my knowledge the 
only language using this sort of ranging syntax is python (corrections 
to this would be welcome).  Other than that we have no existing 
traditions to lean on (to my knowledge).   

Having gotten over my initial objections I will point out a variation 
on your idea that could be very neat.  

Sequence		=	Variable Selection
Subsquence 		=	"[" SelectionString "]"
SelectionString 	=	( (DIGIT | DIGIT "-" [ DIGIT ] )
			|	DIGIT ":" DIGIT )
				*( "," SelectionString)
So expressions like 

var[i] 

would mean the sequence element at offset i.

var[i:j] 

would mean the sequence of elements starting at offset i of length j
( just as it does now).

var[i,j]

would mean the concatenation of the sequence elements at the offsets 
i and j.

var[i-j] 

would mean the sequence of elements from offset i to offset j (inclusive
or not to be decided later).

var[i-] 

would mean the sequence of elements from offset i to the end of the
sequence.  

and we could construct expressions like 

var[i,j,k-l,m,p:q]

etc.  Potentially very powerful.  A bit more difficult to code than 
the other proposals to date.  

Also happens to be backwards compatable to boot.  

Opinions?

Ed