comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Rational for not making cursor tagged in Containers
Date: 23 Apr 2007 17:15:06 -0700
Date: 2007-04-23T17:15:06-07:00	[thread overview]
Message-ID: <1177373706.552914.71270@q75g2000hsh.googlegroups.com> (raw)
In-Reply-To: <y8trvxn2infn.1sxko1eegl1xj$.dlg@40tude.net>

On Apr 23, 12:18 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:

> >>    type GUI_Boolean (Defined : Boolean := True) is (False, True);
>
> >> When Defined = False, the value is rendered as blank and the user is forced
> >> to enter it before it closes the dialog box.
>
> > X, Y : GUI_Boolean;
>
> > If you say X = Y, does it compare just the values, or does it compare
> > the discriminants also?
>
> That depends on how equality operation were defined for the given type. In
> the concrete case of GUI_Boolean, the user-defined "=" would raise
> Constraint_Error if at least one of the discriminants is false.

OK, I've got it.

   function "=" (X, Y : GUI_Boolean) return Boolean is
   begin
      if not X.Defined or else not Y.Defined then
         raise Constraint_Error;
      else
         return X = Y;
      end if;
    end "=";

Is that how you thought this user-defined "=" would be written?


> > What does "X = True" mean?  Does X.Defined have any effect on the
> > value of this expression?
>
> > OK, X is a GUI_Boolean that has Defined=false.  You now want to create
> > Y to be a GUI_Boolean that has the same value as X but Defined=true.
>
> This is semantically wrong for GUI_Boolean. An undefined value has no
> defined value...

I think you've missed the point.  If you want a feature like this in
the language, you can't base the whole semantics on one particular
example you happened to come up with (or that you happened to run
across a use for when you were working on some particular project).
The design of the feature in the language has to be more general than
that, and it has to include cases where a discriminant has some
meaning other than "This value is defined".



> > There are lots of syntactic and semantic issues involved with sticking
> > a discriminant on a scalar that you probably haven't thought through.
>
> All these problems were solved for the type String. In general, the
> problems you have referred equally apply to attributes of values. Ada has
> lots of attributes of values, whether scalar or not. That never was a
> problem.

But if you want the ability to put a discriminant on a scalar, the
meaning of the discriminant is *user*-defined, not language defined.
That isn't the case with any of the attributes on String.  Those
attributes are defined by the language.  I believe that the kinds of
discriminants you refer to pose a whole new set of problems that do
*not* apply to the String type.  For example, you need new syntax just
to allow the programmer to write the user-defined "=" functions that
you've referred to.  For another example, when you have an expression
of type String, the String attributes are defined by the language (at
least in most cases), so all the program has to do is give the values
of the character components; but since a discriminant's meaning is
user-defined, the language has to give the user a way to specify the
correct value; and as one of my examples hinted at, I don't think the
current language syntax is enough to handle this without some pretty
major surgery.

                                          -- Adam




  reply	other threads:[~2007-04-24  0:15 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-19 16:05 Rational for not making cursor tagged in Containers Anh Vo
2007-04-19 18:25 ` Robert A Duff
2007-04-19 19:28   ` Anh Vo
2007-04-19 20:45     ` Robert A Duff
2007-04-19 21:43       ` Dmitry A. Kazakov
2007-04-19 23:59         ` Ray Blaak
2007-04-20  7:54           ` Dmitry A. Kazakov
2007-04-20 10:56             ` Georg Bauhaus
2007-04-20 10:39               ` Dmitry A. Kazakov
2007-04-20 14:42                 ` Georg Bauhaus
2007-04-20 14:45                   ` Georg Bauhaus
2007-04-20 15:13                   ` Dmitry A. Kazakov
2007-04-20 19:37                     ` Georg Bauhaus
2007-04-20 19:32                       ` Dmitry A. Kazakov
2007-04-20 20:59                         ` Robert A Duff
2007-04-20 22:14                           ` Dmitry A. Kazakov
2007-04-23 17:38                             ` Adam Beneschan
2007-04-23 19:18                               ` Dmitry A. Kazakov
2007-04-24  0:15                                 ` Adam Beneschan [this message]
2007-04-24 10:43                                   ` Dmitry A. Kazakov
2007-04-24 16:27                                     ` Adam Beneschan
2007-04-24 20:19                                       ` Dmitry A. Kazakov
2007-04-26  0:58                                         ` Adam Beneschan
2007-04-26  7:50                                           ` Dmitry A. Kazakov
2007-04-26  8:09                                             ` Markus E Leypold
2007-04-27  8:46                                               ` Dmitry A. Kazakov
2007-04-27 11:37                                                 ` Markus E Leypold
2007-04-28 17:35                                                   ` Dmitry A. Kazakov
2007-04-29  2:31                                                     ` Randy Brukardt
2007-04-29  8:45                                                       ` Dmitry A. Kazakov
2007-04-27 20:44                                               ` Robert A Duff
2007-04-26  8:33                                             ` Markus E Leypold
2007-04-26 11:09                                               ` Markus E Leypold
2007-04-20 19:55                       ` Randy Brukardt
2007-04-22  9:54                         ` Georg Bauhaus
2007-04-22 11:19                           ` Dmitry A. Kazakov
2007-04-20 20:44                       ` Robert A Duff
2007-04-21  5:38                         ` Randy Brukardt
2007-04-22  1:14                           ` Robert A Duff
2007-04-22  4:08                             ` Randy Brukardt
2007-04-20 20:11                     ` Randy Brukardt
2007-04-20 21:28                       ` Dmitry A. Kazakov
2007-04-21  5:33                         ` Randy Brukardt
2007-04-21  9:39                           ` Dmitry A. Kazakov
2007-04-22  4:28                             ` Randy Brukardt
2007-04-22  8:38                               ` Dmitry A. Kazakov
2007-04-23 23:26                                 ` Randy Brukardt
2007-04-24 10:43                                   ` Dmitry A. Kazakov
2007-04-24  8:58                                 ` Georg Bauhaus
2007-04-24 12:21                                   ` Dmitry A. Kazakov
2007-04-21  4:48                       ` unifying arrays and records (was Re: Rational for not making cursor tagged in Containers) Ray Blaak
2007-04-20 17:05             ` Rational for not making cursor tagged in Containers Ray Blaak
2007-04-20 18:46               ` Dmitry A. Kazakov
2007-04-20 18:52                 ` Ray Blaak
2007-04-20 19:54                   ` Robert A Duff
2007-04-20  1:18         ` Anh Vo
2007-04-20  7:53           ` Dmitry A. Kazakov
2007-04-20  9:26             ` Maciej Sobczak
2007-04-20 10:15               ` Dmitry A. Kazakov
2007-04-20 11:59           ` Jean-Pierre Rosen
2007-04-20 13:23             ` Anh Vo
2007-04-20 16:02               ` Jean-Pierre Rosen
2007-04-21  2:53                 ` Anh Vo
2007-04-20  3:03   ` Randy Brukardt
2007-04-20  2:53 ` Randy Brukardt
2007-04-20 16:08   ` Anh Vo
replies disabled

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