Closed kirillDanshin closed 7 years ago
do we really need these ambushes in our code?
@onokonem I think we need constructors/destructors, but we should keep migration to goodlang as easy as possible. Why you think it's bad?
needs a new GC. closed until we'll done with it.
Recalling Golang syntax is a major pain, do we have something like 'with' block? If we do we don't need explicit destructors I'd say
@alexclear nope, we don't have that one
I always thought that the name "destructor" was misleading a bit. It's about resource management (well, resource freeing), not about destruction. We're not in malloc() land anymore.
@alexclear note that we plan to add optional manual memory management. so we're not in malloc() land anymore, but kind of.
If
new(*T)
func defined in struct, it will be called vianew(T)
func call. Ifdestruct(*T)
func defined in struct, it will be called when GC will delete the object.To get this done, we should implement multisignatures and allow to define new and destruct funcs in
struct{}
definition.If
destruct(*T)
defined anywhere else, it works like custom functions and should not be called via GC event.User should be able to define
destruct(*T)
in struct anddestruct(*T)
anywhere else in package and it should work as defined above.