I'm trying to understand the design rationale behind the following dm-script function:
TagGroup TagGroupAddLabeledTagGroup(TagGroup tgt_tag_group, String label, TagGroup src_tag_group)
The function's return value is the same src_tag_group
that I pass in. If I already have access to src_tag_group
for later use, why does the function return it again instead of, for example, having a void return type?
Questions:
src_tag_group
in this function design?Any insights into this design decision or links to further documentation would be greatly appreciated.
I can also only speculate, as a lot of the scripting language syntax and curiosities go back 20years or more. Clean-ups have been rare in this time, mainly because "backward compatibility" of old scripts was deemed a lot more important than having a super clean and logical naming and syntax convention.
However, while redundant, returning the (just added) source tagGroup allows for some convenient "pipe-lining" as well, which might be part of why it is like that. ( I do that in a lot of my own classes, rather than returning a void. )
TagGroup TGparent = NewTagGroup() // Whatever parent. Might be a "ImageGetOrCreateTagGroup()
TGparent.TagGroupAddLabeledTagGroup("Group", NewTagGroup()).TagGroupSetTagAsString("Data","mine")
TGparent.TagGroupOpenBrowserWindow(0);
TagGroup TGparent = NewTagGroup();
TagGroup TGChild = TGparent.TagGroupAddLabeledTagGroup("Group 1", NewTagGroup())
TGChild.TagGroupSetTagAsString("Data","mine")
TGparent.TagGroupOpenBrowserWindow(0);