0

I need to know if is possible to serialize a class entirely in XML or json. I don't want to serialize only data but also the algorithms included. I know it could be sound strange but I need it in order to make a generalized job Uploader for a "language-less" grid computing system. Thank you

Vincenzo

1 Answers1

0

In some languages (such as LISP), there is no distinction between code and data in the first place. Many other languages (especially dynamic ones) provide a way to execute code from a string.

Therefore, you can just represent functions as a string of program code that gets executed at the recceiver's side. However, there is no predefined serialization for program code, and extracting it may be complicated in the first place.

To get the code in the first place, you'll have to use some advanced reflection. For example, in Python you can use inspect.getsourcelines.

Community
  • 1
  • 1
phihag
  • 278,196
  • 72
  • 453
  • 469