On Friday, October 29, 2010 10:04:03 Jérôme M. Berger wrote: > Jonathan M Davis wrote: > > Personally, I think that both would be horrible. Having const is great, > > and having non-nullable references could be great, but I sure wouldn't > > want them to be the default. In addition to that, however, having them > > as the default would make porting code from other C-based languages a > > total nightmare - not to mention it totally shatters the general > > principle that either C/C++ code is valid D code with the exact same > > behavior it doesn't compile. That alone makes making them the default > > untenable. > > How does making const and/or non-nullable default break this > principle? If the code relies on nullable variables, then it won't > compile, otherwise it will work exactly the same way as C. > > Jerome
Hmm. I suppose that in the general case it wouldn't (though the change in syntax for const (what would you do, add mutable or unconst?) would certainly result in a _lot_ of code having to be changed), but once you add in shared libraries having non-nullable be the default could be a problem since the code which deals with the fact that something could be null could be disconnected from the code which actually declares the non-nullable references or pointers such that it compiles just fine, but the code which uses it chokes. But you're right that it's not as bad as I was thinking. Regardless, I don't think that it's a good idea. And this late in the game, even if it were a good idea, I think that we should think long and hard before making that large breaking change. D is supposed to be stabilizing now, not making language changes which break tons of code. - Jonathan M Davis
