Documentation of D arrays

Sebastian Biallas groups.5.sepp at spamgourmet.com
Thu Jan 11 18:00:34 PST 2007


Jarrett Billingsley wrote:
> "Sebastian Biallas" <groups.5.sepp at spamgourmet.com> wrote in message 
>> Is there something similar to the "const" keyword of C/C++ in D? It
>> looks a little bit fishy to me, that you can write illegal code in D so
>> easy.. In C/C++ you can return constant array in way, that the caller
>> a) knows, it's constant
>> b) errors are detected at compiler time.
> 
> No, and this issue has been beaten absolutely to death.  I really don't care 
> what happens with this issue.  I've never actually run into any bugs that 
> would be solved by having const, but your mileage may vary, I guess. 
> PLEASE, I don't want to start another topic about this :)

Sorry, I'm new to this newsgroup, will google :)

I'm from the C/C++/Java/Ruby world (not to mention the functional
languages) and these languages have pretty easy constraints:

C: you pass everything by value
C++: you pass by value or by reference (and a reference is -- more or
less -- just a pointer)
Java: you pass either PODs or references(pointers) by value
Ruby: you pass everything by reference

D doen't fit it this categories that well. That arrays are passed by
reference means something different, because an array in D isn't a first
class object (or whatever I should call this).

Well, I guess there are some D idioms which avoid the const array problem.




More information about the Digitalmars-d mailing list