Talk:Halt and catch fire

From Rosetta Code

A bit limited ?

Is this task to be taken literally - halt the CPU - and thus only be applicable to the handful of assembly languages with samples already provided ?
Or does it mean "crash the program" by e.g. dividing by zero or asserting a false condition or raising an unhandled exception or calling exit or...

Whilst reading about the fictitios HCF instruction was entertaining, do we want to encourage people to crash their CPUs ?

--Tigerofdarkness (talk) 21:02, 12 September 2021 (UTC)

I didn't see that the task was to   halt the CPU,   but to   crash the (computer) program.     -- Gerard Schildberger (talk) 21:09, 12 September 2021 (UTC)
Thanks Gerard. What does your impressively minimal REXX program do ? --Tigerofdarkness (talk) 17:24, 15 September 2021 (UTC)
It "crashes" the REXX interpreter,   the messages can vary from REXX to REXX, but for Regina REXX,   the output shown to my terminal   (a Windows DOS "boxed" screen)   is:
─────────────────────────────────────────────────────────────────────────────09/15/2021 13:21:27
c:\►regina haltfire
Error 35 running "c:\haltfire.rex", line 1: Invalid expression
Error 35.1: Invalid expression detected at "="

─────────────────────────────────────────────────────────────────────────────09/15/2021 13:21:29
c:\►

 

      ---  where the 1st two lines are a DOS prompt   (actually, it is one DOS prompt line that is wrapped into two lines)   and
      ---  lines 3 and 4 are the actual (two) error messages from Regina REXX,   
      ---  followed by the DOS prompt   (again, it looks like two lines, but it is a single long DOS prompt that wraps.
      ---  A different REXX interpreter should/may produce similar error messages(s). 
I could've chosen some other character, but a lone equal sign seemed (to me) a very succinct way to "crash" a REXX interpreter without use some other "special" character.       -- Gerard Schildberger (talk) 18:37, 15 September 2021 (UTC)
But... isn't that a compilation error, as opposed to a runtime "crash"? I suspect pretty much every programming language on rc (all 800+ of them) would trigger the same. I think the task is implicitly asking for something more akin to "if 2+2<>4 then = " to compile cleanly and not crash, but "if 2+2<>5 then = " to crash, (and again implicitly) at runtime. Obviously where (the condition and) "=" is language specific. --Pete Lomax (talk) 01:28, 16 September 2021 (UTC)
Well, perhaps one could think of it as a compiler (interpreter) error,   but it is more of an unexpected error that Regina REXX can't recover from.   There are other errors such as a source (REXX statement) that doesn't have a closing quote or comment delimiter,   or a "special" character that has no place in a REXX statement,   or an unexpected left/right parenthesis or comma,   no (closing)   END   for a   DO   or   SELECT   statement, etc.     But this task's requirement was to make the program as short as possible   (crash golf?).   I tried for a concise error that (the current) Regina REXX couldn't recover from and raise the "SYNTAX" error,   which a REXX program could recover from.   Note that REXX can trap and possibly recover from a (statement) syntax error,   and indeed, many REXX programs that have a good deal of boilerplate code that will do just that,   and issue informative error messages to the terminal stating which program was being executed, which statement number failed (and how it failed),   and perhaps what the particular error was (variable not defined, invalid syntax, division by zero, etc.).     However, program recovery wasn't the goal for this Rosetta Code task.     -- Gerard Schildberger (talk) 03:30, 16 September 2021 (UTC)
I also chose a brief syntax error for the Julia example. I think though that the original "halt and catch fire" used to mean exploit a bug in the underlying CPU microcode in order to crash the hardware by having it process an illegal instruction. If this was still possible even with executing raw machine code on recent CPU's I would hope the CPU maker might pay a bounty for information on such an exploit! --Wherrera (talk) 06:59, 16 September 2021 (UTC).
That sort of thing briefly crossed my mind too, but it would be hardware-specific as opposed to programming-language-specific, and therefore somewhat against the primary purpose of this whole site (albeit the op deals primarily in hardware-specific programming languages). Like most everyone else I just assumed we were looking for an emergency "panic" that could be inserted into any other program, and only triggered when some critical test failed, maybe the task should be changed to explicitly ask for that, eg
"It should be possible to insert [a specified subset of] your submission into another program [written in the same language], presumably to help debug it."
The task also asks for the minimum number of lines rather than minimum number of characters, btw. --Pete Lomax (talk) 12:27, 16 September 2021 (UTC)
A single line of one character is about the shortest I could think of (for the REXX example).     -- Gerard Schildberger (talk) 17:56, 16 September 2021 (UTC)
What? Are you being deliberately stubborn or are you [gratuitous and inflammatory insult self-censored]? Let me spell it out for you: one line that consists of (say) 50 characters is not in fact any more lines than one character.... --Pete Lomax (talk) 19:26, 16 September 2021 (UTC)
Neither.   There is no need to be insulting or vulgar.   I merely said that one line of one character is the shortest I could think of.   I never said (as you insultingly implied) that one line of   x   characters is less than one line of   y   characters.   I was not commenting on the   number   of lines, just the number of characters.   Please try to be civil in your choice and tone of words.   This is supposed to be a used to be a friendly website.   Name calling and insults will not bring understanding nor consensus.   It's inflammatory and insulting language like this that is giving Rosetta Code a bad reputation.   Calm down and  then  compose.     -- Gerard Schildberger (talk) 20:08, 16 September 2021 (UTC)
Everyone is calm here. Please educate me on how I should have responded. I am not interested in what you think I should not have said, but what you think I could have said that would be a complete and valid response to that remark, one which is not also a valid response to "This sentence ends in a full stop." Explain to me how that was ever going to add anything to the conversation. For extra bonus points also explain to me how I am not supposed to take that remark&reply as an insult to my intelligence. --Pete Lomax (talk) 11:07, 17 September 2021 (UTC)