comp.lang.ada
 help / color / mirror / Atom feed
From: "Samuel T. Harris" <u61783@gsde.hou.us.ray.com>
Subject: Re: newbie can't get exceptions to work!
Date: Wed, 11 Apr 2001 13:33:49 -0500
Date: 2001-04-11T13:33:49-05:00	[thread overview]
Message-ID: <3AD4A38D.B418FA6E@gsde.hou.us.ray.com> (raw)
In-Reply-To: 86puej8gbu.fsf@acm.org

Laurent Guerby wrote:
> 
> Brian Rogoff <bpr@shell5.ba.best.com> writes:
> > Well, I'm doing what I can on the OCaml mailing list to get nice little
> > features of Ada adopted. In the case of labeled and optional arguments,
> > it's a lot tougher in OCaml than Ada, which has type inference and higher
> > order functions. If you look at the recent discussions on the mailing
> > list, Jacques Garrigue (the label inventor and main proponent) is laying
> > out the alternatives and it looks like the only way to get commuting
> > labels is to have labels be non-optional. I don't like that.
> 
> I see label and optional arguments being two separate issue. If you do
> only labels, it shouldn't cause any problem at all, you can even
> disallow overloading with only label changes while keeping most of the
> interesting thing about labels (call site clarity). But even keeping
> overloading should be near trivial.
> 
> Optional argument are a whole different beast, and I think much less
> useful, and I think likely to cause trouble.
> 
> Is it that the conjunction of both feature is being considered and
> hence the problems (my advice would be to just drop optional
> arguments), or am I missing something obvious?
> 

Agreement here (mostly). Say a subprogram has an optional parameter.
The parameter is optional because the subprogram specification
has a default expression for the parameter specification.

It is a trivial refactoring to define a new subprogram
of the same name and the same argument profile except
it is missing the optional argument. The new subprogram's
body is a one-liner calling the first subprogram while
supplying the default expression. The first subprogram
is changed to exclude the default expression. One can
even pragma inline the new subprogram.

This refactoring causes NO code changes on callers.

So, what did the optional argument (i.e. default
parameter initial expression) buy me in the first place?

1. The default expression can be an important for
   its documentation value and not is effect of making
   the parameter optional.

2. What if I have a subprogram with many optional
   parameters? The above subprogram refactoring
   needs to provide new subprograms for every
   combination of present and missing parameters.
   That can be alot of subprograms.

3. Using optional parameters employs a conservation
   of declarations. One declaration handle two variations.
   Imaging package ada.text_io being specified with
   two of every put and get routine because the form
   parameter is optional.

As counter-point to the above benefits of optional
parameters, consider a real problem we experienced.
Using the VADS Ada compiler, we extensively use
the current_exception.exception_name function call.
Migrating to Apex we were pleased to find it defines
just such a call so we did not feel a problem on
this portability issue. That is until I discovered,
through Apex complaining about it, that some of our
code uses a subprogram rename declaration and that
this subprogram rename declaration would not compile
because Rational had added an optional parameter
to current_exception.exception_name. This clearly
shows that a subprogram with an optional parameter
is NOT semantically equivalent to two subprograms,
one with and one without, said parameter.

-- 
Samuel T. Harris, Principal Engineer
Raytheon, Aerospace Engineering Services
"If you can make it, We can fake it!"



  reply	other threads:[~2001-04-11 18:33 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-05  3:19 newbie can't get exceptions to work! Jeff Shipman
2001-04-05  4:25 ` Ed Falis
2001-04-05 11:00   ` martin.m.dowie
2001-04-05 14:21     ` Ted Dennison
2001-04-05 17:50       ` Fraser Wilson
2001-04-05  4:34 ` Jeff Shipman
2001-04-05  4:59 ` Wilhelm Spickermann
2001-04-05 14:14   ` Ted Dennison
2001-04-05 16:37     ` Wilhelm Spickermann
2001-04-06 13:09     ` Marc A. Criley
2001-04-06 15:04       ` Ted Dennison
2001-04-06 16:43       ` Robert A Duff
2001-04-06 17:39         ` Ted Dennison
2001-04-06 21:50           ` Robert A Duff
2001-04-06 20:11         ` Brian Rogoff
2001-04-06 22:20           ` Robert A Duff
2001-04-06 23:04             ` Brian Rogoff
2001-04-07  5:48               ` Jeffrey Carter
2001-04-10  1:29                 ` Robert A Duff
2001-04-07 19:30               ` Robert A Duff
2001-04-07 21:17                 ` Brian Rogoff
2001-04-07 21:25                   ` Ayende Rahien
2001-04-07 22:57                     ` David Starner
2001-04-08 12:10                       ` Ayende Rahien
2001-04-08  2:12                     ` Larry Hazel
2001-04-08 12:12                       ` Ayende Rahien
2001-04-09 16:20                         ` Larry Hazel
2001-04-10  2:38                           ` Ayende Rahien
2001-04-10  3:25                             ` James Rogers
2001-04-08 22:18                       ` Brian Rogoff
2001-04-09 15:14                         ` Ted Dennison
2001-04-09 17:23                           ` Brian Rogoff
2001-04-09 18:23                             ` Laurent Guerby
2001-04-09 19:15                               ` Brian Rogoff
2001-04-10 18:21                                 ` Laurent Guerby
2001-04-10 19:44                                   ` Brian Rogoff
2001-04-11 18:03                                     ` Laurent Guerby
2001-04-11 18:33                                       ` Samuel T. Harris [this message]
2001-04-14  0:06                                         ` Robert A Duff
2001-04-12  1:42                                       ` Mike Silva
2001-04-12  2:38                                       ` Brian Rogoff
2001-04-12 23:23                                         ` Laurent Guerby
2001-04-13  2:44                                           ` Brian Rogoff
2001-04-11 13:24                                   ` Ayende Rahien
2001-04-11 13:14                                     ` Mats Karlssohn
2001-04-11 15:08                                       ` Ayende Rahien
2001-04-11 21:42                                       ` Fraser Wilson
2001-04-12 23:55                                         ` Robert A Duff
2001-04-10  2:12                               ` Robert A Duff
2001-04-10  3:47                                 ` Brian Rogoff
2001-04-10 13:40                                 ` Ada keywords (was: Re: newbie can't get exceptions to work!) Marin David Condic
2001-04-10 14:26                                   ` Jean-Pierre Rosen
2001-04-09 20:49                             ` newbie can't get exceptions to work! Ted Dennison
2001-04-09 21:44                               ` Brian Rogoff
2001-04-09 21:59                                 ` Ted Dennison
2001-04-10  2:54                                   ` Ayende Rahien
2001-04-10 14:00                                     ` Ted Dennison
2001-04-10 17:44                                     ` Fraser Wilson
2001-04-10  6:59                               ` Mats Karlssohn
2001-04-10 14:18                                 ` Ted Dennison
2001-04-10 16:27                                   ` Mark Biggar
2001-04-11 11:55                                     ` Mats Karlssohn
2001-04-11 14:34                                       ` Samuel T. Harris
2001-04-11 15:50                                         ` Pat Rogers
2001-04-12  6:27                                         ` Mats Karlssohn
2001-04-11 11:49                                   ` Mats Karlssohn
2001-04-11 15:38                                     ` Robert A Duff
2001-04-13 16:12                             ` Matthew Woodcraft
2001-04-10  1:41                   ` Robert A Duff
2001-04-10  3:03                     ` James Rogers
2001-04-10  3:58                       ` Brian Rogoff
2001-04-10 21:48                         ` Ted Dennison
2001-04-11 15:09                           ` Ayende Rahien
2001-04-11 21:57                             ` James Rogers
2001-04-11 23:13                               ` Brian Rogoff
2001-04-12  6:33                                 ` Mats Karlssohn
2001-04-12 16:38                                   ` Brian Rogoff
2001-04-17  7:04                                     ` Mats Karlssohn
2001-04-17  9:08                                       ` Jean-Pierre Rosen
2001-04-12 15:16                               ` Ted Dennison
2001-04-12 21:22                                 ` James Rogers
2001-04-10  4:26                     ` Brian Rogoff
2001-04-11 15:30                       ` Robert A Duff
2001-04-11 17:33                         ` Brian Rogoff
2001-04-10  1:26               ` Robert A Duff
2001-04-10  2:11                 ` Brian Rogoff
2001-04-14  0:00                   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2001-04-05  5:26 Christoph Grein
replies disabled

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