comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Limited use for limited with?
Date: Sat, 9 Oct 2010 01:29:24 -0500
Date: 2010-10-09T01:29:24-05:00	[thread overview]
Message-ID: <i8p246$mvf$1@munin.nbi.dk> (raw)
In-Reply-To: 37e167dc-1741-4627-bef4-1fd8b32bdbeb@c10g2000yqh.googlegroups.com

"Maciej Sobczak" <see.my.homepage@gmail.com> wrote in message 
news:37e167dc-1741-4627-bef4-1fd8b32bdbeb@c10g2000yqh.googlegroups.com...
...
>Important note: in my design dangling pointers are prevented not by
>registry or its obscure API, but by the purpose of the whole. In 100%
>cases that are known to me the objects outlive the registry, so there
>is no possibility to create dangling pointers.

I suppose it depends upon the use. If you are the *only* person that will 
ever work on this code, and you never make mistakes, then that might in fact 
be OK.

>Granted, users *can* write an artificial and nonsense code (perhaps to 
>prove
>the point) that will create dangling pointers, but no amount of protection 
>will
>prevent such intentional misuse.

Careful: I agree that intentional misuse (such as using Unchecked_Conversion 
to avoid checks) isn't really protectable. But most misuse is accidental, 
and can even happen by someone that knows better.

It's really easy to declare an object inside of a subprogram by mistake. 
Someone (probably you) *will* do it sometime soon. Accessibility *might* 
protect you, but I've only have one single instance in my entire programming 
career where I was able to use 'Access; everywhere else I *had* to use 
'Unchecked_Access (usually because the argument was a parameter) -- so I 
wouldn't count on that to be much help.

If there are other programming using your packages, then you pretty much 
have to assume these sorts errors will happen. So what do you want to happen 
when someone accidentally misuses your code? The entire program mysteriously 
locks up? Or some sort of detection? I know which I prefer -- in Claw, we 
went to great lengths to ensure that everything will work cleanly no matter 
where someone declares a window -- in part because handling support calls 
are expensive. (And even helping programmers on your team in such cases is 
expensive.)

>> It's always better to prevent abuse in the interface.
>
>Unless the "protection" makes the system unusable. Clarity and ease of
>use are important goals, too. Ironically, they even promote
>correctness.

True, but there is nothing clear about a callback registry. It completely 
sacrifies safety (not just via dangling pointers, but also type safety) in 
order to make something easier for the programmer (the one person for whom 
"ease" is irrelevant). I think it is just a hack.

                              Randy.





  reply	other threads:[~2010-10-09  6:29 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-28  7:37 Limited use for limited with? Maciej Sobczak
2010-09-28  9:04 ` Alex R. Mosteo
2010-09-30  7:24   ` Stephen Leake
2010-09-30  9:21     ` Alex R. Mosteo
2010-09-28  9:18 ` Ludovic Brenta
2010-09-28 12:59   ` Maciej Sobczak
2010-09-28 13:45     ` Dmitry A. Kazakov
2010-09-28 21:57       ` Maciej Sobczak
2010-09-29  6:03         ` Ludovic Brenta
2010-09-29  8:25           ` Maciej Sobczak
2010-09-29  7:51         ` Dmitry A. Kazakov
2010-09-29  8:38           ` Maciej Sobczak
2010-09-29  9:16             ` Dmitry A. Kazakov
2010-09-29 12:22               ` Maciej Sobczak
2010-09-29 13:41                 ` Dmitry A. Kazakov
2010-09-29 15:07                   ` Georg Bauhaus
2010-09-29 19:22                     ` Dmitry A. Kazakov
2010-09-29 20:51                   ` Maciej Sobczak
2010-09-29 21:18                     ` Dmitry A. Kazakov
2010-10-05  7:35                     ` Randy Brukardt
2010-10-08  8:05                       ` Maciej Sobczak
2010-10-09  6:29                         ` Randy Brukardt [this message]
2010-10-05  7:25             ` Randy Brukardt
2010-10-08  8:23               ` Maciej Sobczak
2010-10-09  6:13                 ` Randy Brukardt
2010-10-10 14:13                   ` Maciej Sobczak
2010-10-11  6:23                     ` Randy Brukardt
2010-10-12 19:29                       ` Maciej Sobczak
2010-10-12 20:19                         ` Dmitry A. Kazakov
2010-10-13  2:09                         ` Randy Brukardt
2010-10-13  8:44                           ` Georg Bauhaus
2010-10-15  0:59                             ` Randy Brukardt
2010-10-13  9:43                           ` Maciej Sobczak
2010-09-28 15:15     ` Ludovic Brenta
2010-09-28 22:04       ` Maciej Sobczak
2010-09-28 15:54   ` Robert A Duff
2010-09-30  7:27   ` Stephen Leake
2010-09-30  7:33     ` Ludovic Brenta
2010-09-30 16:03     ` Adam Beneschan
2010-10-07 11:55       ` Stephen Leake
2010-10-07 18:27         ` Martin Krischik
2010-10-07 21:30           ` Adam Beneschan
2010-10-09  6:29             ` Martin Krischik
2010-10-09 18:35               ` Robert A Duff
2010-10-08  0:07           ` Randy Brukardt
2010-10-09  6:21             ` Martin Krischik
2010-09-28  9:32 ` Vadim Godunko
2010-09-28 11:34 ` stefan-lucks
2010-09-28 13:15   ` stefan-lucks
2010-09-28 16:55 ` Adam Beneschan
2010-09-28 17:31   ` Robert A Duff
2010-09-28 19:24     ` Adam Beneschan
2010-09-28 20:32       ` Vadim Godunko
2010-09-28 21:32         ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox