that might do it, the closures are actually being made by a New(type) call, 
and i was basically fixated by returning only the new instance (and maybe a 
error), but no reason not to return a callback destructor.

maybe New isn't the right name anymore?

the idea is to incrementally add a registry of instances of a interface{}, 
for optimisation, and using defer to maintain it by making sure an instance 
is de-registered.

On Sunday, 21 January 2018 21:33:38 UTC, matthe...@gmail.com wrote:
>
> Have the closure generator return the resource?
>
> https://play.golang.org/p/16pyo0gh8_s
>
> I'm not sure what you mean by using types instead, or even why you are 
> trying to do this. Can you explain more?
>
> Matt
>
> On Sunday, January 21, 2018 at 3:17:20 PM UTC-6, simon place wrote:
>>
>> i wrote the code below hoping that defer() would run when a funcs context 
>> was lost, not just when it ended.(which, without using closures, would 
>> always be the same thing, i think.)
>>
>> https://play.golang.org/p/HBrmBOkK1zJ
>>
>> as can be seen it doesn't, which begs the question;
>>
>> "how do you clean up external resources used in a closure?"
>>
>> this problem came up when i was incrementally developing code containing 
>> closures, it seems at this point i am forced to switch everything to use 
>> types instead! which seems to make use closures at all a bit problematic. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to