Posted 31 May 2015 - 07:53 PM
I am trying to make a program that makes an error quine using the following algorithm:
Start out with a seed (A piece of code that errors)
Take the error the code produces and make that error the new program (Done with a remote program)
Continue step 2 until the source code of the program = the error it produces
This is my code in the main program (This is in golf.lua and the program the seed is in is newgolf.lua, I know the name of the programs are weird, they were just empty lua files I had)
Start out with a seed (A piece of code that errors)
Take the error the code produces and make that error the new program (Done with a remote program)
Continue step 2 until the source code of the program = the error it produces
This is my code in the main program (This is in golf.lua and the program the seed is in is newgolf.lua, I know the name of the programs are weird, they were just empty lua files I had)
r = 0
s = "newgolf.lua"
while true do
h = io.open(s, "r")
l = h:read("*all")
h.close()
tempfunc, errmsg = loadfile(s)
if errmsg == l then
print(r)
break
else
r = r+1
h = io.open(s, "w")
h:write(errmsg)
h:close()
print(r..": "..errmsg)
end
end
If I make the seed in newgolf.lua something like oi;gzsjgd or anything where I just bang my head against my keyboard it works as expected, however if I put valid "looking" lua code that actually errors (Something like printfunction({}) ) it says that errmsg is nil even though tempfunc would error. Why is this, and how can I fix it?