Top 5

Steven Schveighoffer schveiguy at yahoo.com
Fri Oct 10 06:44:41 PDT 2008


"Christopher Wright" wrote
> Sergey Gromov wrote:
>> Wed, 08 Oct 2008 15:07:27 -0500,
>> Andrei Alexandrescu wrote:
>>> Ok, per Aarti's suggestion: without speaking officially for Walter, let 
>>> me ask this - what do you think are the top issues you'd like to see 
>>> fixed in D?
>>
>> I'd generally like less syntactic freedom in D.  Excessive amounts of 
>> syntactic sugar cause troubles in many different places.  Economy of 
>> syntax principle has a flip side: a single mistake can make your program 
>> mean a whole different thing instead of simply giving you a syntax error. 
>> Redundancy is required to detect an error and suggest a fix.
>>
>> 1.  Drop the "array is a slice" idea.  I liked it a lot when I saw the D 
>> specs but it bit me immediately while I implemented a text parser.  The 
>> idea sounds nice but it causes too many problems.
>>
>> There are two major use cases for arrays: building and parsing.  When 
>> building, you want fast append, you've got a limited number of arrays, 
>> and you likely don't care if your arrays are a little fat.  When parsing, 
>> you want data consistency, that is you don't want a sub-array to change 
>> if you occasionally append to another sub-array.  You also want to pass 
>> those sub-arrays around a lot and you probably want them to be cheap.
>
> Catenating an array to a slice shouldn't do it in place unless the slice 
> includes the end of the original array. If it does, that's a bug.

You'd think so, but you have it exactly backwards.  In the current 
implementation a slice will append in place only if it contains the 
BEGINNING of an allocated array.

I wrote a proposal a while back to do exactly what you said, and it can be 
done with minimal overhead in the GC.  But it has been ignored AFAIK.

-Steve 





More information about the Digitalmars-d mailing list