Issue #11630 has been updated by Lionel PERRIN.


The python API around lambda and function objects makes possible to implement serialization of lambda, for instance with https://github.com/apache/spark/blob/master/python/pyspark/cloudpickle.py. I'm looking for a ruby equivalent feature.

In addition to Proc#has_side_effect? and Proc#get_external_variables, one may of course require Proc#source_code.

----------------------------------------
Feature #11630: possibility to serialize Proc or Lambda
https://bugs.ruby-lang.org/issues/11630#change-54633

* Author: Lionel PERRIN
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
It would create a reliable alternative to gems like https://github.com/ngty/sourcify and thus makes much easier to implement the ruby-spark gem (https://github.com/ondra-m/ruby-spark).

I assume that it implies the Proc API to include methods like: Proc#get_external_variables.

To keep a seamless behavior of a deserialized Proc, it is important to add also a method like: Proc#has_side_effect?. This method would be return true if the Proc modifies at least one of its parameters or one of the external variables. (I have the feeling that this development might be a duplicate for issues/6806)

One extra feature would be to have these two methods available for Method as well: Method#get_external_variables (returning the instance variables) and Method#has_side_effect?



-- 
https://bugs.ruby-lang.org/