comp.lang.ada
 help / color / mirror / Atom feed
From: Stefan.Lucks@uni-weimar.de
Subject: Re: Functions vs constants
Date: Thu, 24 Jul 2014 09:20:15 +0200
Date: 2014-07-24T09:20:15+02:00	[thread overview]
Message-ID: <alpine.DEB.2.11.1407240850160.24422@debian> (raw)
In-Reply-To: <lqpc07$d05$1@loke.gir.dk>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3040 bytes --]

On Wed, 23 Jul 2014, Randy Brukardt wrote:

> I think you miss the point. This isn't something that one intentionally
> writes (and "Error" is a terrible name just used for an example). But if one
> intends to reuse code, the client has no control over the naming of the
> entities in the reused code. Moreover (and more important), the client
> shouldn't break due to unrelated maintenance on some third-party code.
> Especially if that third-party code decides to add something with the same
> name as something that you are already using. How could they know to avoid
> it?

It would be nice if Ada had a selective "use" clause, a bit like MODULA2's 
import:

   from Ada.Text_IO use Put, New_Line;

Now the programmer could write Put("Hello"); New_Line; but would have to 
resort to prefix notation for Ada.Text_IO.Put_Line("Hello").

This would keep your namespace free from any new identifiers the 
maintainer of Ada.Text_IO can add to the package. (Yes, Ada.Text_IO isn't 
the best example for this issue ...)

> One could imagine a rule "no use clauses of any kind, anywhere", but that's
> not really practical (especially as it means no infix operator usage).

What about allowing "use type <id>" and "use all type <id>", but 
not "use <id>"?

> In
> the absence of that, you're going to be at risk for problems. Moreover, even
> if "prefixes are good", they also make code unreadable (particularly if you
> have lots of child packages).

What about using rename?

   package PFS renames My_Project.Abstract_IO.Persistent_File_Storage;

> SPARK avoids overloading because the original authors of the tools didn't
> have enough knowledge of how to implement it.

Claiming them not to "have enough knowledge" is unfair!

SPARK has originally been written for Pascal, which doesn't support 
overloading (or didn't at that time). So the designed their tools such 
that they did heavily depend on subprogram's unique names. E.g., the 
information the toolset did generate for a subprogram was stored in a file 
with the subprogram's name.

When they changed to Ada, they didn't start from scratch, but used the 
back-end they had originally written for Pascal. Adaption to beyond-Pascal 
properties of Ada clearly had a low priority for them.

You could see that even in the output: When a hypothesis (i.e, a 
precondition) required two entities to be different, the SPARK toolset's 
output would use the Pascal symbol for not equal, rather than Ada'S "/=".

While changing the output symbol would not have been a big issue, adapting 
to overloading clearly would imply a huge amount of work, with things 
breaking all over the toolset.

> They then explained that as a
> "benefit", but the only benefit is that it simplified their tools.

Agreed!


------  I  love  the  taste  of  Cryptanalysis  in  the morning!  ------
     <http://www.uni-weimar.de/cms/medien/mediensicherheit/home.html>
--Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universität Weimar, Germany--

  reply	other threads:[~2014-07-24  7:20 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 21:18 Functions vs constants Victor Porton
2014-07-21 21:28 ` Victor Porton
2014-07-21 21:49   ` Shark8
2014-07-21 21:52     ` Victor Porton
2014-07-21 21:59       ` Adam Beneschan
2014-07-21 21:35 ` Niklas Holsti
2014-07-21 21:41   ` Victor Porton
2014-07-21 23:23   ` Randy Brukardt
2014-07-22  7:42     ` Dmitry A. Kazakov
2014-07-22 22:07       ` Randy Brukardt
2014-07-23  7:55         ` Dmitry A. Kazakov
2014-07-23 21:44           ` Randy Brukardt
2014-07-23 12:37         ` G.B.
2014-07-23 22:12           ` Randy Brukardt
2014-07-24  7:20             ` Stefan.Lucks [this message]
2014-07-25  4:43               ` Randy Brukardt
2014-07-26  2:36                 ` Shark8
2014-07-24  8:27             ` Georg Bauhaus
2014-07-24 10:11               ` Dmitry A. Kazakov
2014-07-24 10:49                 ` G.B.
2014-07-24 12:50                   ` Dmitry A. Kazakov
2014-07-25  4:56               ` Randy Brukardt
2014-07-25  6:45                 ` Georg Bauhaus
2014-07-25 10:46                   ` G.B.
2014-07-25 19:31                   ` Randy Brukardt
2014-07-25 20:02                     ` Dmitry A. Kazakov
2014-07-26  2:45                       ` Shark8
2014-07-26  8:02                         ` Dmitry A. Kazakov
2014-07-26 14:03                           ` Shark8
2014-07-26 14:18                             ` Dmitry A. Kazakov
2014-07-21 21:55 ` Victor Porton
2014-07-22  7:06 ` Maciej Sobczak
2014-07-22  7:50   ` Dmitry A. Kazakov
2014-07-22 22:14     ` Randy Brukardt
2014-07-23 13:21       ` Stephen Leake
2014-07-23 13:27         ` Victor Porton
2014-07-23 15:10         ` Adam Beneschan
2014-07-23 21:57 ` Robert A Duff
2014-07-24 12:25   ` Victor Porton
2014-07-24 15:53     ` Robert A Duff
2014-07-24 15:57       ` Victor Porton
2014-07-24 16:47   ` Pascal Obry
2014-07-24 12:26 ` anon
2014-07-24 12:52 ` Victor Porton
2014-07-24 16:01   ` Robert A Duff
2014-07-24 16:15     ` Adam Beneschan
2014-07-25  5:05     ` Randy Brukardt
replies disabled

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