#Follow-up question... In the other
1 messages · Page 1 of 1 (latest)
But where do I return the values of my fields?
You mean return the value of the constructor being invoked?
To clarify something:
- When your module constructor (as in,
func New()in the Go SDK) is invoked you will get- parent name == name of the module
- function name ==
""
- When the engine asks your module for its typedefs during init (i.e. returns
dagger.Module), then- parent name ==
""
- parent name ==
Sorry, in your last message I misread "constructor" and thought you were referring to the init where it has to returns its typedefs
oooh
I guess I wasn't sure what to call it
Now I understand that "init" and "constructor" are 2 distinct invocations
No you saying "constructor" is correct, that's my bad, I just read too quickly
is "" as a function name only legal when the parent name is the module name?
Yes
Is the constructor always called, even if no arguments have been declared for it, and the module type has no declared fields?
No it's only invoked if explicitly declared via a typedef by the module. If it's not declared then the engine just installs an automatic stub one that doesn't require invoking the module
Ah, TypeDef.WithObject().WithConstructor()?
Yes exactly
is the name of the constructor important?
(dag.Function() requires a name argument)
Also it requires a return type argument... how do I avoid a cycle?
No it's not significant. It's weird that it's required (amongst the other weirdness here)
I guess I don't have to use literally the same dagger.TypeDef instance, as long as the type name matches
ie. right now I have:
root := dag.TypeDef().WithObject(call.ModuleName)
with constructor it becomes:
root := dag.TypeDef().WithObject(call.ModuleName)
fnConstructor := dag.Function(call.moduleName, root)
root = root.WithConstructor(fnConstructor)
Yes exactly, you can just provide the object name as a string and don't need to provide all the other typedefs. As long as the rest of the typedefs for the object are defined elsewhere you can just stub it out by name there