Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not sure if this is what you're looking for, but any programming language can be made to function this way. For any programming language P, define the language P<sub>always</sub> as follows:</p> <ul> <li>If p is a valid program in P, then p is a valid program in P<sub>always</sub> whose meaning is the same as its meaning in P.</li> <li>If p is <strong>not</strong> a valid program in P, then p is a valid program in P<sub>always</sub> whose meaning is the same as a program that immediately terminates.</li> </ul> <p>For example, I could make the language C++<sub>always</sub> so that this program:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { cout &lt;&lt; "Hello, world!" &lt;&lt; endl; } </code></pre> <p>would compile as "Hello, world!", while this program:</p> <pre><code>Hahaha! This isn't legal C++ code! </code></pre> <p>Would be a legal program that just does absolutely nothing.</p> <p>To solve your original problem, just take any OOP language like Java, Smalltalk, etc. and construct the appropriate Java<sub>always</sub>, Smalltalk<sub>always</sub>, etc. language from it. Again, I'm not sure if this is at all what you're looking for, but it could be done very easily.</p> <p>Alternatively, consider finding a grammar for any OOP language and then using that grammar to produce random syntactically valid programs. You could then filter those programs down by using the P<sub>always</sub> programming language for that language to eliminate syntactically but not semantically valid programs.</p>
 

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