Separate structure allocation and constructors
Registered by
Amos Wenger
Currently constructors are translated to things like:
struct Object* Object__new() {
struct Object* this = malloc(
// do stuff with this
return this;
}
And super/this constructor calls are handled by copying code from super/this cosntructors into the caller. This leads to code duplication and should be avoided by splitting memory allocation and constructor calling, e.g.
Thing t = new Thing();
Would generate code
struct Thing* t = malloc(
Thing__new(t);
This approach has several advantages: avoid code duplications in constructors, ie.:
void Thing__new(struct Thing* this) {
SuperClass_
}
It also allows calling constructors not only at the beginning but anywhere in a constructor.
Blueprint information
- Status:
- Not started
- Approver:
- Amos Wenger
- Priority:
- Undefined
- Drafter:
- Amos Wenger
- Direction:
- Needs approval
- Assignee:
- Amos Wenger
- Definition:
- Approved
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by
Related branches
Related bugs
Sprints
Whiteboard
(?)