comp.lang.ada
 help / color / mirror / Atom feed
From: sbelmont700@gmail.com
Subject: Re: Class wide preconditions: error in the Ada 2012 Rationale?
Date: Mon, 5 Nov 2012 17:04:10 -0800 (PST)
Date: 2012-11-05T17:04:10-08:00	[thread overview]
Message-ID: <715c26cd-06c2-40c1-8317-eacd228b1ebc@googlegroups.com> (raw)
In-Reply-To: <op.wnbifyvyule2fv@cardamome>

On Monday, November 5, 2012 3:41:57 PM UTC-5, Hibou57 (Yannick Duchêne) wrote:
> 
> I believe either my understanding is wrong, or the Rationale is wrong. The  
> 
> above statements are not compatible with the substitution principle. What  
> 
> if a sub-program expects a a class wide type with a root type and its  
> 
> precondition, and get a derived type with a specific precondition it can't  
> 
> know about?
> 

A foundation of the LSP is that you should not be strengthening preconditions for derived types.  After all, when you substitue a child for a parent, you cannot know anything about the child, which includes any additional preconditions that have been added.  If classwide preconditions are checked at the point of the call, then it might dispatch to subprograms with preconditions that haven't even been written yet (that it clearly cannot check beforehand).

-sb



  parent reply	other threads:[~2012-11-06  1:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05 20:41 Class wide preconditions: error in the Ada 2012 Rationale? Yannick Duchêne (Hibou57)
2012-11-05 20:43 ` Yannick Duchêne (Hibou57)
2012-11-06  1:04 ` sbelmont700 [this message]
2012-11-09  0:57 ` Randy Brukardt
2012-11-09  1:32   ` Yannick Duchêne (Hibou57)
2012-11-09  2:13     ` Randy Brukardt
replies disabled

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