comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: API design considerations - variable-length array in record type
Date: Mon, 8 Oct 2012 22:45:49 -0700 (PDT)
Date: 2012-10-08T22:45:49-07:00	[thread overview]
Message-ID: <e5c8581e-c5c0-431c-a5fc-4fe2682ce221@googlegroups.com> (raw)
In-Reply-To: <80f9a7cb-47fc-4573-9e2d-4efbe919416d@googlegroups.com>

On Monday, October 8, 2012 11:16:28 PM UTC-6, Adam Beneschan wrote:
> 
> Note that this will not work on all implementations.  There are two ways to implement an array component whose bound depends on a discriminant: (1) the record type will contain space for the largest possible array, or 

I think that's only an issue if the discriminant itself has a default value.
(Something to do with view-changing, now that you mention this possible problem.)

> (Other methods are possible in theory.)

I'd like to know what those theories are.

> (P.S. Is it just me, or is anyone else irritated by the use of Natural'First or Positive'First?  

I'm more irritated there's no 'type attribute so you can't say something like Type K( X : Enum_21:= X'Type'First ) [...] for specifying that you do want the type to have a defaulted discriminant, and that should be the 'First of that type. {After-all the type of X has to be known at compile-time.} Though that particular example might not be the best; using X before it's declaration is illegal. -- Though the idea could be useful other places.

> if you have a subtype S, you should usually say S'First instead of coding the literal value, because who knows what reason you might have in the future for deciding to change the declaration of S, and then you only have to change it in one place.  But I don't see the point of Natural'First.  It will always be 0, on all implementations, and can never be changed no matter how many times you redesign your program, so why not just write 0?  OK, that's my one rant for the day.)

I usually do it to remind myself that I'm dealing w/ subtypes. {That is, it helps me to think in terms of sets/subsets.}



  reply	other threads:[~2012-10-09  5:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-08  9:03 API design considerations - variable-length array in record type Maciej Sobczak
2012-10-08 11:13 ` Simon Wright
2012-10-08 11:29 ` Egil Høvik
2012-10-08 11:53   ` Maciej Sobczak
2012-10-08 14:37     ` Tero Koskinen
2012-10-09  2:02 ` Shark8
2012-10-09  5:16   ` Adam Beneschan
2012-10-09  5:45     ` Shark8 [this message]
2012-10-09  5:42   ` Niklas Holsti
2012-10-09  3:10 ` Stephen Leake
2012-10-09  7:47   ` Maciej Sobczak
replies disabled

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