Unlike your example, writeln = "hello" is actually valid, correct code. That
is, it's not utterly stupid, it's just utterly ugly (to you and me). If
someone wants to call writeln that way because they like the "style", then
that's their choice. I see no difference from what you propose.
It's not about the compiler rejecting terrible code because it thinks the code
is terrible, it's about the compiler rejecting terrible code because the
library author thinks it's terrible. That is, the library author can decide
how you should use their code, just like he decides which functions are private
and public.
I understand your frustration for having existing code break. All I can offer
is at least the broken code will provide an error and line number where you can
fix it.
There are many people who refuse to move to D2 because of the const semantics.
They say "my code works fine without const, I don't see why I should have to
change it. D2 const sucks!" But const can be a very useful thing *if* you use
it correctly. So it's a tradeoff. I feel the property syntax as it currently
stands is out of control, bug prone, and needs to be reined in. You feel it's
just what you need, and you use it to great effect. Nobody is 100% right, but
with strict properties, things look better because you have the freedom to name
your methods without worry that they are misused. I see it as a huge gain.
I also don't like the new operator overloading scheme in D2, since there are
oodles of problems with template methods and classes, but they are much more
powerful than the old method. Since the old methods are unofficially still
there, I have something to fall back on for dcollections, but I expect some day
to have to drop all references to the old operator overloading functions. Is
it frustrating? Yes. Does it seem pointless? Yes. But my single opinion and
my library cannot be the reason that an obviously better system isn't adopted.
-Steve
>________________________________
>From: David Simcha <[email protected]>
>To: Discuss the phobos library for D <[email protected]>
>Sent: Friday, April 22, 2011 3:39 PM
>Subject: Re: [phobos] Time to get ready for the next release
>
>
>
>
>
>On Fri, Apr 22, 2011 at 3:26 PM, Steve Schveighoffer <[email protected]>
>wrote:
>
> Like it or not, the same thing applies to things like:
>>
>>writeln = "hello";
>>
>>Even though we know this is not the right way to call it, the compiler
>>doesn't give an error to enforce the semantics.
>>
>>
>>-Steve
>>
>Ok, but just because you can do something utterly stupid like this doesn't
>mean you should. You can also do the following even though it's a terrible
>idea, because it's impossible for the compiler to reject every terrible idea
>without rejecting some good ideas:
>
>import std.random;
>
>// Overwrite random memory locations with random data until the program
>// crashes
>void main() {
> while(true) {
> auto num = uniform(0, int.max);
> auto ptr = cast(int*) num;
> *ptr = uniform(0, int.max);
> }
>}
>
>Again, I'd be more sympathetic to your point of view if making these changes
>didn't also break existing code. For me this is the tiebreaker. I have
>already designed a whole API around methods-as-properties. I'm sure having
>tons of code break will be very aggravating to a lot of people. Given the
>weak arguments put forth in favor of strict semantics, I can't bring myself to
>say that breaking not only existing code but whole existing API designs is
>justified.
>
>BTW, as far as your argument about static typing, this may be a fundamental
>disagreement between us. I don't like static typing, but consider it a
>necessary evil in exchange for performance and the ability to do low-level
>work. Therefore, I want only as much static typing as is necessary for these
>to be possible.
>
>_______________________________________________
>phobos mailing list
>[email protected]
>http://lists.puremagic.com/mailman/listinfo/phobos
>
>_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos