| |
| Posted by claptrap in reply to Walter Bright | PermalinkReply |
|
claptrap
Posted in reply to Walter Bright
| On Sunday, 15 December 2024 at 03:11:10 UTC, Walter Bright wrote:
> On 12/14/2024 4:39 PM, Paul Backus wrote:
>> That way, you can get the informational/educational value of -preview=safer without breaking your build, and you're only forced to satisfy the checks once you actually decide to transition to @safe.
>
> Safer is turned on with a switch. You can turn it on, see what you want to address, then turn it off.
I think his point is that it wont "educate people", or wont push people to do what you think it will. I mean you're assuming that if you do X it will encourage people to do Y. Like "make casts ugly and people will use them less", I don't think that works. I means there's lots of psychologic research on "nudging" people towards more desirable behaviour. But its often counterintuitive. One example I remember is when they did an experiment where they fined parents who dropped their kids of late to nursery. It made the problem worse because parents were like "I can just pay the fine". What actually worked was when they made it so that if you're late you have to go in to talk to the secretary and sign in a book for being late. What they learnt from the parents was the fine made it easier, they can just pay the fine and feel less guilt about being late. Whereas talking to the secretary was embarrassing, and **emphasised** that they were not doing what they should.
So if you really want to encourage people toward safety, maybe have the compiler *always* print a report on the memory safety issues, something like..
"42 memory issues found, uses the "-safebydefault" switch to find out more"
That will keep nudging people, and also gamify it a bit. People like having a metric they can work on.
It **may** also work on the grounds that people will want the number as low as possible if they are publishing their code. I mean if everyone will see that message when its compiled.
Oh yeah the another one I remember was that putting little plastic balls in urinals made guys significantly less likely to pee on the floor.
|