Well I can think of numerous reasons why you would want a string representation of a function.
My specific use case is for sharing code between machines via a web service. The client needs to be able to serialize code and send it to the web service.
I've also used this in other languages to do things like build dependency trees between functions. For example:
function a()
return b() + c()
end
function b()
return 2
end
function c()
return d() * d()
end
function d()
return 4
end
I might have a function:
solve_system(a, b, c, d)
If I can serialize the body of those functions then I can construct the tree using regex or a similar strategy:
a - b
|
c - d
I then know that b and d need to be evaluated first, then c, then a, in order to solve the system.