Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>q(x) is true for any x of T and q(y) is true for any y of S =&gt; S is a subtype of T </code></pre> <p>The answer is <strong>No</strong>. What the expression means is that a common supertype R of S and T could be defined, and that then the LSP (shame on how that name became mainstream) would hold for T->R and S->R.</p> <p>In typing theory, there are types, that include semantics, and there are implementations of the types that abide to the semantics, perhaps by inheriting implementations. </p> <p>In practice, the only reasonable way to specify the semantics of a type (the <code>q(x)</code> part) is through an implementation, so we are left with semantic-less signatures in the form of <em>interfaces</em>, and <em>classes</em> that inherit for implementation purposes, and implement the interfaces they like, with no way to check if they are doing it correctly.</p> <p>Researches have tried to define <em>formal languages</em> to specify types, so tools can check if an implementation abides to type definitions, but the effort is so large that it would do as good to compile the formal language into executable code. It's a <em>Catch-22</em> situation that I think will never be solved.</p> <p>Back to your original question, in languages that allow what today is called "Duck Typing", the answer is undecidable, because an object of any type can be passed to any function, and the typing is right if the correct signatures are implemented and the result is right. Let me explain...</p> <p>In a language like <a href="http://en.wikipedia.org/wiki/Eiffel_%28programming_language%29" rel="nofollow">Eiffel</a> you could place a postcondition on <code>List.append()</code> that <code>List.length()</code> must increase after the operation. That is not the way languages like Perl, JavaScript, Python, or even Java work. That lack of type-strictness allows for much more succinct code than stricter type definitions would.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload