comp.lang.ada
 help / color / mirror / Atom feed
From: john@nospam.demon.co.uk (John McCabe)
Subject: Re: Dynamic discrimants in variant records?
Date: Thu, 19 Jun 2003 10:37:32 +0000 (UTC)
Date: 2003-06-19T10:37:32+00:00	[thread overview]
Message-ID: <3ef190e6.9372917@news.btclick.com> (raw)
In-Reply-To: bcrt83$mdpd5$1@ID-175126.news.dfncis.de

On Thu, 19 Jun 2003 10:44:21 +0200, Vinzent Hoefler
<ada.rocks@jlfencey.com> wrote:

>Well, so far so good, I can perfectly define a corresponding type
>statically. Deciding which of the registers to use for what region of
>memory statically is probably quite ok for most real world cases, but
>I really would like to have a little bit more flexibility.
>
>As mentioned, the actual (global) variables of this type are memory
>mapped registers, so the problem occurs when I want to change a region
>register dynamically (from a 4K granularity to a 64K for instance). In
>Ada this would be equivalent to just change some of the discrimants
>(those are really some bits in the register) and so changing the
>interpretation of the record.
>
>AFAICS this is not allowed in Ada, once a variable of a specific type
>is declared I cannot change its discriminants anymore. Is there any
>nice Ada-ish way around this?

>Or IOW, how would someone do that what I want in the most efficient
>way? Declaring an appropriate type each time and use an unchecked
>conversion to apply it to the "real" memory mapped register?

It may be worth reading about mutable and immutable discrimnated
types. Whether you can change the discriminant of an object after it
is created depends on whether default values have been assigned to the
discriminants etc. I can't remember the exact details but "Ada as a
Second Language" is, I seem to remember, quite good on this.

It may also be worth reading the following message and thread.

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.10.1046461270.1343.comp.lang.ada%40ada.eu.org


Best Regards
John McCabe

To reply by email replace 'nospam' with 'assen'



  reply	other threads:[~2003-06-19 10:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-19  8:44 Dynamic discrimants in variant records? Vinzent Hoefler
2003-06-19 10:37 ` John McCabe [this message]
2003-06-19 23:57 ` Jeffrey Carter
2003-06-20  7:44   ` Vinzent Hoefler
replies disabled

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