This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ardera's profile picture

Expand textutils.serialize

Started by ardera, 19 August 2012 - 02:58 PM
ardera #1
Posted 19 August 2012 - 04:58 PM
Its only a very little suggestion, and I don't think its really needed, but you can save functions as strings.

string.dump(thefunction)

returns the string of the function, so textutils.serialize could serialize functions, and loaded programs!
(loadfile(pathtofile) returns the file as a function)
Noodle #2
Posted 19 August 2012 - 05:02 PM
I like the idea but I don't see the need..
You could just do
code = [[
function forward
turtle.forward()
end ]]
rednet.send(id, code)
ardera #3
Posted 19 August 2012 - 05:18 PM
yes, but its costly… you can send the whole (almost the whole) _G table without opening the bios and sending the strings of a function
Sebra #4
Posted 19 August 2012 - 05:25 PM
There are problems with string.dump result.
Strings with high bit saved/loaded with errors.
ardera #5
Posted 20 August 2012 - 08:46 AM
I only have errors if I use string.dump with functions like term.write…
immibis #6
Posted 20 August 2012 - 01:10 PM
What happens to upvalues?
Xtansia #7
Posted 20 August 2012 - 01:34 PM
What happens to upvalues?

They dissappear into the ether :D/>/>
Sebra #8
Posted 20 August 2012 - 04:48 PM
I only have errors if I use string.dump with functions like term.write…
Show me your file io. Is it binary?
What happens to upvalues?
Is seems they become nils.