comp.lang.ada
 help / color / mirror / Atom feed
* discriminants, what are they?
@ 2006-12-17 23:57 markww
  2006-12-18  0:33 ` Robert A Duff
  2006-12-18  9:35 ` gautier_niouzes
  0 siblings, 2 replies; 5+ messages in thread
From: markww @ 2006-12-17 23:57 UTC (permalink / raw)


Hi,

Can explain what an Ada discriminant is? I found this definition but
I'm new to Ada so I can't quite understand the technical definition.

http://www.grammatech.com/rm95html-1.0/rm9x-03-07.html

Thanks




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: discriminants, what are they?
  2006-12-17 23:57 discriminants, what are they? markww
@ 2006-12-18  0:33 ` Robert A Duff
  2006-12-18  0:43   ` markww
  2006-12-18 10:23   ` Dmitry A. Kazakov
  2006-12-18  9:35 ` gautier_niouzes
  1 sibling, 2 replies; 5+ messages in thread
From: Robert A Duff @ 2006-12-18  0:33 UTC (permalink / raw)


"markww" <markww@gmail.com> writes:

> Hi,
>
> Can explain what an Ada discriminant is? I found this definition but

It's a parameter that can be passed to a type when making an object of
the type, sort of like a parameter passed to a procedure when making a
call to that procedure.  It can be used inside the type to determine which
variant you want, or the bounds of an array, or to pass further along to
another discriminant of a component type, or in an expression that
initializes a component.

Another view: it's a constant component.  Once you give a discriminant
of a particular object a value, that value cannot change.

> I'm new to Ada so I can't quite understand the technical definition.
> 
> http://www.grammatech.com/rm95html-1.0/rm9x-03-07.html

Indeed, this technical definition is rather arcane.  You should look at
a textbook or tutorial that gives examples.

That's not even the latest version of the Ada RM, by the way...

- Bob



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: discriminants, what are they?
  2006-12-18  0:33 ` Robert A Duff
@ 2006-12-18  0:43   ` markww
  2006-12-18 10:23   ` Dmitry A. Kazakov
  1 sibling, 0 replies; 5+ messages in thread
From: markww @ 2006-12-18  0:43 UTC (permalink / raw)


Thanks Bob, that's what I was looking for,

Mark

Robert A Duff wrote:
> "markww" <markww@gmail.com> writes:
>
> > Hi,
> >
> > Can explain what an Ada discriminant is? I found this definition but
>
> It's a parameter that can be passed to a type when making an object of
> the type, sort of like a parameter passed to a procedure when making a
> call to that procedure.  It can be used inside the type to determine which
> variant you want, or the bounds of an array, or to pass further along to
> another discriminant of a component type, or in an expression that
> initializes a component.
>
> Another view: it's a constant component.  Once you give a discriminant
> of a particular object a value, that value cannot change.
>
> > I'm new to Ada so I can't quite understand the technical definition.
> >
> > http://www.grammatech.com/rm95html-1.0/rm9x-03-07.html
>
> Indeed, this technical definition is rather arcane.  You should look at
> a textbook or tutorial that gives examples.
>
> That's not even the latest version of the Ada RM, by the way...
> 
> - Bob




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: discriminants, what are they?
  2006-12-17 23:57 discriminants, what are they? markww
  2006-12-18  0:33 ` Robert A Duff
@ 2006-12-18  9:35 ` gautier_niouzes
  1 sibling, 0 replies; 5+ messages in thread
From: gautier_niouzes @ 2006-12-18  9:35 UTC (permalink / raw)


Maybe an example can help...

a definition:
http://homepage.sunrise.ch/mysunrise/gdm/uza_html/unzip__ads.htm#253_8
the type in action:
http://homepage.sunrise.ch/mysunrise/gdm/uza_html/unzip__adb.htm#567_15

HTH
______________________________________________________________
Gautier         -- http://www.mysunrise.ch/users/gdm/index.htm
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: discriminants, what are they?
  2006-12-18  0:33 ` Robert A Duff
  2006-12-18  0:43   ` markww
@ 2006-12-18 10:23   ` Dmitry A. Kazakov
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitry A. Kazakov @ 2006-12-18 10:23 UTC (permalink / raw)


On Sun, 17 Dec 2006 19:33:27 -0500, Robert A Duff wrote:

> "markww" <markww@gmail.com> writes:
> 
>> Can explain what an Ada discriminant is? I found this definition but
> 
> It's a parameter that can be passed to a type when making an object of
> the type, sort of like a parameter passed to a procedure when making a
> call to that procedure.  It can be used inside the type to determine which
> variant you want, or the bounds of an array, or to pass further along to
> another discriminant of a component type, or in an expression that
> initializes a component.
> 
> Another view: it's a constant component.  Once you give a discriminant
> of a particular object a value, that value cannot change.

and with a subtype declaration some of the discriminants can be fixed to
distinct values, e.g. to produce "specializations."

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-12-18 10:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-17 23:57 discriminants, what are they? markww
2006-12-18  0:33 ` Robert A Duff
2006-12-18  0:43   ` markww
2006-12-18 10:23   ` Dmitry A. Kazakov
2006-12-18  9:35 ` gautier_niouzes

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