# Closure serialization.

- Thread: https://externals.io/message/43644
- Original archive: https://news-web.php.net/php.internals/43644
- Started by Richard Quadling on 2009-04-07T07:55:09+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #43644 — Richard Quadling — 2009-04-07T07:55:09+00:00

URL: https://externals.io/message/43644#43644

Hi.

Currently you cannot serialize a closure. That certainly makes sense.

But would it be possible/feasible that a closure could be serialized
if the value returned was the byte code used by the engine to execute
the compiled closure?

Or is this one of the "don't go there" ideas I sometimes get?

Regards,

Richard Quadling.

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

---

## #43645 — Lukas Kahwe Smith — 2009-04-07T08:38:50+00:00

URL: https://externals.io/message/43644#43645 · In reply to: #43644

> Hi.
>
> Currently you cannot serialize a closure. That certainly makes sense.
>
> But would it be possible/feasible that a closure could be serialized
> if the value returned was the byte code used by the engine to execute
> the compiled closure?
>
> Or is this one of the "don't go there" ideas I sometimes get?


I guess its a dont go there thing, as you also run into trouble with  
"use"-d variables.

regards,
Lukas Kahwe Smith
mls@pooteeweet.org

---

## #43646 — Guilherme Blanco — 2009-04-07T08:50:38+00:00

URL: https://externals.io/message/43644#43646 · In reply to: #43645

Although this may open a lot of pitfalls, I'd support the idea to
serialize Closures.

My concern is about recovering a Closure from a user-persisted state.
People are able to do weird things, and we should be aware of that.
Just need to keep in mind of a dictate that says: "Never underestimate
the ignorance of a person".


Cheers,


>
> 
>
> > […]
>
>
> I guess its a dont go there thing, as you also run into trouble with "use"-d
> variables.
>
> regards,
> Lukas Kahwe Smith
> mls@pooteeweet.org
>
>
>
>
> --
> 
> 
>
>



-- 
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9215-8480
MSN: guilhermeblanco@hotmail.com
URL: http://blog.bisna.com
São Paulo - SP/Brazil

---

## #43652 — johannes@php.net — 2009-04-07T11:22:42+00:00

URL: https://externals.io/message/43644#43652 · In reply to: #43645

Hi,


> > […]
[...]
> I guess its a dont go there thing, as you also run into trouble with  
> "use"-d variables.

In the long run,  I guess, we should try to reach it. Ignoring the use
stuff there were some ideas floating in the past, like storing the
source or using APC or ... but not with 5.3.

johannes
