Why I Use D

Scott S. McCoy tag at cpan.org
Sun Mar 30 12:52:18 PDT 2008


On Sun, 2008-03-30 at 16:41 -0300, Leandro Lucarella wrote:

> 
> In python this is array[5:-1], which seems a lot nicer to me...
> 
> I hope D some can do array[5..-1], array[..-4], array[..], etc. a la
> Python.


Fwiw, this is a feature Python borrowed from Perl.  In Perl, a negative
index means "array length - Y".  But 5..-1 doesn't seem as pretty as 5..
I mean, if I didn't tell it where to go, where else is it going to go?
Inference is nice, we seem to all agree...I don't hear anyone
complaining about not having to specify their types in for-each
loops...so why not infer the beginning or end of the array, I mean...

if i say array[..5], where was I expecting to start other than the
beginning?


> 
> > So it only buys you the luxury of not having to type $ in one very
> > special case. In my view, that makes keeping it more consistent than
> > dropping it. (And come on - it's only one character!)
> 
> Yes, only 1 character but it looks like an ugly hack to me. '$' has no
> meaning except in array slices, and what not necessary anyway. I know
> it's
> hard (impossible?) to get rid of it now, but I wanted to say it =)


I wouldn't think it'd be impossible.  D 2.0 is considered unstable.
Walter seems to be being careful not to make people too angry by
breaking their code.  My thoughts on that is "If the code you were
writing was important, it shouldn't have been in D 2 anyway since D 2
isn't done."  Although I appreciate that digital mars provides a
functional implementation of a totally in-development language
specification.  That's pretty cool beans.  People should be glad, not
bitch about stuff breaking.  You rarely get that type of luxury in other
languages.

Cheers,
    Scott S. McCoy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20080330/11ac7977/attachment.html>


More information about the Digitalmars-d mailing list