195
64
Try to write some code in your language and make it not satisfying our criteria of being a programming language any more.
A language satisfies our criteria (simplified version for this challenge) of being a programming language if:
- It can read user input representing tuples of positive integers in some way.
- It can output at least two different possible results depending on the input.
- It can take two positive integers and add them (and the result can affect the output).
- It can take a positive integer and decide whether it is a prime (and the result can affect the output).
- For the purpose of this challenge, any kind of output that isn't an allowed output method for a normal challenge is ignored. So it doesn't matter whether the program can also play a piece of music, or posting via HTTP, etc.
- Update: You can also choose one or some of the allowed output methods, and ignore all the others. But you must use the same definition everywhere in the following criteria. And if your program can disable more than one output methods — that worths more upvotes.
Examples like making it not able to output, or disabling all the loop constructs so it won't be able to do primality test and making sure the user cannot re-enable them.
You should leave a place for inserting new code. By default, it is at the end of your code. If we consider putting the source code in that place in your answer and running the full code as a complete program the interpreter of a new language, that language should not satisfy the criteria.
But the inserted code must be executed in such a way like a language satisfying the criteria:
- The inserted code must be grammatically the same as something (say it's a code block in the following criteria) that generally do satisfy the criteria, from the perspective of whoever wants to write a syntax highlighter. So it cannot be in a string, comment, etc.
- The inserted code must be actually executed, in a way it is supposed to satisfy the criteria. So it cannot be in an unused function or
sizeof
in C, you cannot just execute only a non-functional part in the code, and you cannot put it after an infinite loop, etc. - You can't limit the number of possible grammatically correct programs generated this way. If there is already something like a length limit in the language you are using, it shouldn't satisfy the criteria even if this limit is removed.
- You can't modify or "use up" the content of input / output, but you can prevent them from being accessed.
- These criteria usually only applies to languages without explicit I/O:
- Your code should redirect the user input (that contains informations of arbitrary length) to the inserted code, if a code block isn't usually able to get the user input directly / explicitly in the language you are using.
- Your code should print the returned value of the inserted code, if a code block isn't usually able to output things directly / explicitly in the language you are using.
- In case you print the returned value, and it is typed in the language you are using, the returned type should be able to have 2 different practically possible values. For example, you cannot use the type
struct {}
orstruct {private:int x;}
in C++.
This is popularity-contest. The highest voted valid answer (so nobody spotted an error or all errors are fixed) wins.
Clarifications
- You shouldn't modify the code in the text form, but can change the syntax before the code is interpreted or compiled.
- You can do other things while the code is running. But the reason that it doesn't satisfy the criteria should be within the inserted code itself. It can error because of the interference of another thread, but not just be killed by another thread.
- All the specs basically means it should be grammatically likely satisfying the criteria if all the built-ins were not changed but not actually do. It's fine if you find any non-grammatical workarounds, such as passing the parameters to the code block correctly, but make them not able to be used in some way.
- Again, the inserted code must be actually executed. Code after an infinite loop or crashing is considered "not actually executed", thus not valid. Those answers might be interesting, but there are already some other infinite loop or crashing questions on this site, and you may find a more appropriate one to answer. If not, consider asking a new question. Examples of those questions are:
Leaderboard
var QUESTION_ID=61115/*,OVERRIDE_USER=8478*/;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,/*getComments()*/(more_answers?getAnswers():process())}})}/*function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}*/function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),score:s.score,language:a[1],lang:jQuery('<div>').html(a[1]).text(),link:s.share_link})}),e.sort(function(e,s){var r=e.score,a=s.score;return a-r});var s={},r=1,a=null,n=1;e.forEach(function(e){e.score!=a&&(n=r),a=e.score,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",e.n=n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.score).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text())/*,s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}*/});var t=e/*[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o])*/;t.sort(function(e,s){return (e.lang.toUpperCase()>s.lang.toUpperCase())-(e.lang.toUpperCase()<s.lang.toUpperCase())||(e.lang>s.lang)-(e.lang<s.lang)});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{PLACE}}",o.n).replace("{{LANGUAGE}}",o.language).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.score).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<(?:h\d|(?!.*<h\d>)p)>\s*((?:[^,;(\s]| +[^-,;(\s])+)(?=(?: *(?:[,;(]| -).*?)?\s*<\/(h\d|p)>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;float:left}table{width:250px}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=7509797c03ea"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Score</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Sorted by Language</h2> <table class="language-list"> <thead> <tr><td></td><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{PLACE}}</td><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
Am I allowed to change the code before executing it? Also, can I run other code whilst I am running the code given? – Blue – 2015-10-18T12:30:01.190
@muddyfish Basically no and yes. See the clarifications. – jimmy23013 – 2015-10-18T12:53:15.250
If it wasn't for
#{...}
, I'd have a neat GolfScript answer... – Dennis – 2015-10-18T13:01:52.897What about code that executes an infinte loop, so your code after it never gets executed. Is that valid? – pppery – 2015-10-18T14:13:20.427
@ppperry If the inserted code is after the infinite loop so it is not executed, then no. If the inserted code runs into a infinite loop itself, it's fine. – jimmy23013 – 2015-10-18T15:23:29.340
I'm not sure what the update means. If the intention is that it's sufficient to break
print
statements and you can claim to be ignoring output to a file then I think the current wording allows you to claim to be ignoring all standard output mechanisms. – Peter Taylor – 2015-10-18T19:15:42.430@PeterTaylor How? And note that the grammatically equivalent reference must satisfy the criteria in any definition you choose. – jimmy23013 – 2015-10-18T19:37:12.653
What do you mean by that? That if you want to ignore all output mechanisms, you have to provide a new one? – Peter Taylor – 2015-10-18T21:03:56.707
And if so, that seems to be in stark contradiction to the way you haven't complained that the answers which close stdin are violating the rule "Your code should redirect the user input (that contains informations of arbitrary length) to the inserted code, if a code block cannot get the user input directly in the language you are using.". – Peter Taylor – 2015-10-18T21:26:29.577
21This could have made a really great cops and robbers challenge I think. – DankMemes – 2015-10-18T23:07:28.580
6@DankMemes Agreed. As it stands, it's much too vague, and most answers would be invalidated by finding a workaround. CnR with this premise would be delightful. – Mego – 2015-10-18T23:54:30.770
@PeterTaylor You should choose at least one output mechanism and ignore all other mechanisms. For the later comment, I have changed "cannot" to "isn't usually able to". It's only meant to prevent answers doing nothing in a language without explicit IO. – jimmy23013 – 2015-10-19T10:10:31.007
@Sp3000 Rephrased that part a bit and hope it became clearer. – jimmy23013 – 2015-10-19T10:19:41.410
@DankMemes There is a related cops-and-robber in the sandbox by feersum, which removed the part about hacking existing languages, but just write a new language for the robbers to use. – jimmy23013 – 2015-10-19T10:22:28.640
3So then it seems to be saying that in languages with explicit IO it's permissible to do completely boring things like reading and discarding the contents of stdin. It sets up a completely unfair playing field where some languages require you to carefully handle the IO for the inserted code, and other languages allow you to trash it and deny IO to the inserted code. – Peter Taylor – 2015-10-19T12:28:00.910
@PeterTaylor Added a criteria to disallow it. I'm not sure this solves all the problems. – jimmy23013 – 2015-10-19T13:04:16.073
I assume this is not allowed, but figured i would check: can I modify the user code at runtime? – pseudonym117 – 2015-10-19T22:08:23.737
@pseudonym117 No. See clarifications. – jimmy23013 – 2015-10-19T22:50:56.760
What about solutions that redefine some of the required operations to produce invalid output, like 2 + 2 = false? – jdphenix – 2015-10-20T02:03:38.883
A lot of the answers below make the new inserted code error out. Is that OK? I mean, is it OK to modify your runtime/language in such a way that all new code are errors? – slebetman – 2015-10-20T05:14:29.040
@jdphenix That's ok, and is the supposed way solving this challenge. – jimmy23013 – 2015-10-20T06:58:15.297
@slebetman I think it is ok. Technically, only "limiting the number of possible grammatically correct programs" is currently forbidden. – jimmy23013 – 2015-10-20T07:04:02.077
Are these answers satisfying what you were looking for? Break the language so it's unusable or were you hoping for something else? – Luminous – 2015-10-20T13:04:16.880
@Luminous Some of them doesn't. The intention was to break the language by redefining the language, not by running into an infinite loop, etc, which is a normal features of any Turing-complete language. – jimmy23013 – 2015-10-20T14:03:28.237
@jimmy23013 the clarifications do not exactly clarify what i meant to ask. What I meant was can I do something like this (using .NET as an example): before the IL code is JIT compiled to native code, change all of the IL op codes in the user program into NOPs. So the instructions would be called, they would just do nothing. – pseudonym117 – 2015-10-20T19:46:16.187
@pseudonym117 I think it shouldn't be allowed, as the NOPs doesn't exist in the original program. But upvote the following comment if you think it should be allowed. – jimmy23013 – 2015-10-21T09:37:31.623
Does PHP count? – Alec Teal – 2015-10-22T14:58:25.367
@AlecTeal Why not? – jimmy23013 – 2015-10-22T15:33:00.290
@jimmy23013 you missed the joke. – Alec Teal – 2015-10-22T16:31:53.257
@jimmy23013 My answer changes the
Code
but not theco_code
. Should it be allowed? – Blue – 2015-10-22T18:27:43.783Hmmm. Guess the "do no harm" oath didn't exactly make it to software engineering? Oh well. Makes it more interesting. Set the controls for the center of the Sparc. – HostileFork says dont trust SE – 2015-10-22T19:28:29.283
@Dr.Rebmu It's not always easy to do harm, though, and some of the harmful unusable jails are broken by someone else. And welcome back here. – jimmy23013 – 2015-10-23T14:59:19.693
@muddyfish You can change how the code is interpreted, or the supporting libraries, etc, or the behavior of the compiler before the code is parsed / compiled / linked into that, but not the part the code itself compiled into, after it is compiled. – jimmy23013 – 2015-10-23T15:03:57.400
@jimmy23013 I may or may not finish my language, new tricks up my sleeve coming, but I stopped by because this was "trending" in the sidebar. So no promises. – HostileFork says dont trust SE – 2015-10-24T12:23:50.240
Can program runtime be considered output? EG if I have STDIN but not STDOUT, is simply running for a different length of time based on primality of input number enough? – Shelvacu – 2015-10-26T08:03:43.673
@shelvacu No. That's not an allowed output method and is ignored. – jimmy23013 – 2015-10-26T08:17:27.170
Deleted the poll comments. An answer compiling the inserted code and modifying the compiled code isn't allowed. – jimmy23013 – 2015-10-27T12:32:02.727
Apparently I'm not allowed to post an answer on this question, but would
– starbeamrainbowlabs – 2015-11-28T10:43:57.597exec gzip $0
count for bash? It makes the currently executing script hide in a box, refusing to come out until you manually unpack it. Inspired by this answer.Could I do something that prevents any code from running? e.g.
while (true) {} // insert code here
– J Atkin – 2016-02-10T23:43:56.407@JAtkin No. Read the question carefully. – jimmy23013 – 2016-02-10T23:55:11.687
I can do it in 0 bytes, check out my answer :) – Noah Cristino – 2017-07-10T20:07:53.360
This is quite possible the best pop-con I have ever seen. – Gryphon – 2017-07-10T23:41:16.527
2Are we allowed to use a language that's already unusable to begin with? (JavaScript for example) – 12Me21 – 2017-10-17T14:23:32.283
Am I allowed to just shut off output? Then there would be no way to extrapolate any data – KrystosTheOverlord – 2019-10-21T13:19:14.813