Why I Use D

Scott S. McCoy tag at cpan.org
Sun Mar 30 15:26:10 PDT 2008


You also could if array[5 .. -3] implied length -3.

Similarly. array[-3] could imply array[array.length -3]...

But someone suggested against that, atleast for non-compile time
checking.  I would agree, for the non-literal instance that a negative
integer of -5 shouldn't result in magical figuring out if the element
needs to be pulled from the front or the back.  But the literal case
adds expressiveness, I think.

Cheers,
    Scott S. McCoy

On Sun, 2008-03-30 at 22:54 +0200, Simen Kjaeraas wrote:

> On Sun, 30 Mar 2008 22:43:11 +0200, Walter Bright  
> <newshound1 at digitalmars.com> wrote:
> 
> > Scott S. McCoy wrote:
> >> array[5..] and array[..5] seem to make perfect sense to me and get rid  
> >> of kludge like $.
> >
> > If $ were implicit, you couldn't do things like:
> >
> > 	array[5 .. $-3]
> 
> 
> You could if it were only optional.
> 
> --Simen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20080330/a64d5578/attachment.html>


More information about the Digitalmars-d mailing list