comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: MI is sloppy
Date: Thu, 11 Dec 2008 15:44:30 -0600
Date: 2008-12-11T15:44:30-06:00	[thread overview]
Message-ID: <ghs1ki$vaf$1@munin.nbi.dk> (raw)
In-Reply-To: 1g29uf1ygl1wc$.1x184o2bk9m0k$.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:1g29uf1ygl1wc$.1x184o2bk9m0k$.dlg@40tude.net...
> On Wed, 10 Dec 2008 18:40:46 -0600, Randy Brukardt wrote:
...
>> I tend to think so. These are insufficiently different to be types; there
>> should only be one type and different subtypes. Subtypes imply runtime
>> checks, but with good contracts most such errors can still be detected by
>> tools. And you don't have the goofy restrictions that come with trying to
>> make things separate types that aren't logically separate.
>
> Huh, I don't see any difference. Semantically
>
>   type Inout_File is ...
>   procedure Get (File : in out Inout_File; Item : out Data);
>   procedure Put (File : in out Inout_File; Item : Data);
>
>   subtype In_File is ...;
>   procedure Get (File : in out Input_File; Item : out Data) is abstract;
>
>   subtype Out_File is ...;
>   procedure Put (File : in out Output_File; Item : Data) is abstract;
>
> Whatever way you go, incrementally adding operations or else incrementally
> removing them.

No, that's not what I meant. I meant something like:

type File is ...
subtype Inout_File is ...
subtype In_File is ...
subtype Out_File is ...
procedure Get (A_File : in out File; Item : out Data)
with precondition A_File not in In_File;
procedure Put (A_File : in out File; Item : Data)
with precondition A_File not in Out_File;

> But the second is certainly worse because it is statically uncheckable,

Yes, that's the idea in general. I think that static analysis could detect 
95% of the errors, and the rest of course would be detected by exceptions. 
(And with good exception contracts, those too could be made errors if 
desired.)

>.. it is a "God-class,"

Pretty much everything real ends up that way anyhow. Is there really any 
need to extend a good container class? Most of the counter-examples are 
acedemic cases that rarely occur in practice. (Yes, inheritance works great 
for windowing GUIs. And hardly anything else. So maybe it is the GUI that is 
the unusual and oddly designed case??)

> it is potentially inefficient when only input is used,
> etc. (It is not the way programs are designed, if we could pick a ready
> program from the pool of all possible programs. (:-))

Link-time compilation (a basic part of the overall design of Janus/Ada, just 
not practical until very recently) would eliminate most of the 
inefficiencies, just as it has the potential to eliminate most of the 
inefficiencies of generic code sharing and defaulted parameters. But it 
wouldn't put static roadblocks into your way or magic inheritance where you 
need fancy tools just to figure out what operations are available for a 
type. (That's surely the case with Claw.)

As far as not being the way that programs are designed, well, the way that 
they have been designed hasn't worked out that well, so differences 
shouldn't be that harmful.

>> This is very much like the attempt to statically check accessibility
>> (lifetime) of objects. It doesn't work, at least not in general. And we 
>> have
>> much better technology in terms of detecting errors without goofy
>> restrictions than we did when these rules were defined, so why not use
>> them??
>
> I just do not believe that. IF there is a tool capable to read my mind and
> understand the program semantics and the reasonably warn me, THEN, please,
> build it into the compiler and make those warnings errors. If there is
> something (badly wrong) with that, then I don't need neither this tool nor
> its features in the compiler.

No, actually I agree with you here - the tool should be part of the 
compiler. But I don't think it can be part of the *language definition*; it 
doesn't make sense to say that a compiler needs to be smart enough to 
optimizations across units, nor force it to be dumber than that if it *can* 
make such optimizations. That sort of language definition only works if 
there is exactly one compiler.

In any case, I think we need to see such static analysis working in 
compilers before trying to mandate it. And there isn't any such at the 
moment. If anyone has a half-a-million dollars that they'd like to spend on 
Ada, I surely would like to try... :-)

                                               Randy.






  reply	other threads:[~2008-12-11 21:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-06 10:09 MI is sloppy (was: Construction initialization problem) Dmitry A. Kazakov
2008-12-06 17:16 ` Georg Bauhaus
2008-12-06 21:16   ` Martin Krischik
2008-12-06 21:35     ` Maciej Sobczak
2008-12-07  9:12   ` MI is sloppy Dmitry A. Kazakov
2008-12-07 15:38     ` Georg Bauhaus
2008-12-07 20:04       ` Dmitry A. Kazakov
2008-12-11  0:40 ` MI is sloppy (was: Construction initialization problem) Randy Brukardt
2008-12-11 10:02   ` MI is sloppy Dmitry A. Kazakov
2008-12-11 21:44     ` Randy Brukardt [this message]
2008-12-11 23:17       ` Georg Bauhaus
2008-12-12 10:06         ` Dmitry A. Kazakov
2008-12-12  9:59       ` Dmitry A. Kazakov
2008-12-12 10:50         ` Georg Bauhaus
2008-12-12 11:15           ` Dmitry A. Kazakov
2008-12-12 12:15             ` Georg Bauhaus
2008-12-12 13:35               ` Dmitry A. Kazakov
2008-12-12 14:29                 ` Georg Bauhaus
2008-12-12 14:59                   ` Dmitry A. Kazakov
2008-12-13  0:08                 ` Randy Brukardt
2008-12-13  9:54                   ` Dmitry A. Kazakov
replies disabled

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