Irakli Gozalishvili wrote:
  Hi,

I keep running into cases where I would like to know if function is
pure. Although my interpretation of pure is not quite right but I don't
know any better name. By pure in this context I would refer to functions
that don't access an out scope variables and don't
do any mutations of itself or it's properties no references to itself
could be an option too. My intended use case for such a feature is to

IOW, 'stateless'; or 'serializable'. For in fact it means, that I can send f.toString() to the other side and when evaled, I can use it.

processes too, it would be great if we had something like
Function.isPure(f). Also as far as I know jits already capture this info
for optimisation purposes maybe it could be exposed ? Another
alternative could be pure(function() { …. }) that would throw compile
error if
function followed is not pure.

Yes, it could be nice to have some API to help with this. Maybe not generic isPure or the like, maybe Function.serialize(f) and Function.deserialize(serialized_f) would be enough, the former returning null if not pure/stateless/serializable.

It is good to note that the function is serializable not only if it has no outer pointers, but also when its outer pointers only point to 'known primitives' (numbers, strings, null, true, false; not symbols).


Thanks!
--
Irakli Gozalishvili
Web: http://www.jeditoolkit.com/

Herby
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to