ThisIsNotARealLanguage
Jump to navigation
Jump to search
User:Maxsteele2 It's NOT like this:
NOT A CODE DON'T PRINT "Hello, World!"
It's not like that, for this is not a real language. So fuck off.
Implementation
A — theoretical — implementation in the Common Lisp programming language shall be supplied. In the case of a successful interpretation, one of several messages will selected in an aleatory manner and printed to the standard output. A failure in the code evaluation will cause an error to be signaled.
By adding further entries to the +SUCCESS-MESSAGES+ sequence the behavior may be extended.
(declaim (type (vector string *) +SUCCESS-MESSAGES+))
(defparameter +SUCCESS-MESSAGES+
(coerce
'("Hello, World!"
"..."
"Really?"
"ThisIsNotARealLanguage"
"egaugnaLlaeRAtoNsIsihT"
"René Magritte disagrees!"
"But this may be a real pipe."
"It is Not Even DOOM Music.")
'(vector string *))
"A vector of the possible messages to randomly print in the case of a
successful ThisIsNotARealLanguage program's interpretation.")
(defun interpret-ThisIsNotARealLanguage (code)
"Interprets the piece of ThisIsNotARealLanguage code and returns no
value."
(declare (type string code))
(if (string= code "NOT A CODE
DON'T PRINT \"Hello, World!\"")
(format T "~&~a"
(aref +SUCCESS-MESSAGES+ (random (length +SUCCESS-MESSAGES+))))
(error "The code ~s was even less valid than expected." code))
(values))
(setf *random-state* (make-random-state T))
An exemplary invocation, expected to succeed, constitutes the following:
(interpret-ThisIsNotARealLanguage "NOT A CODE DON'T PRINT \"Hello, World!\"")