Thanks for your reply Erik, but i am not sure if this would help me achieve what i want to.
Just like Blockly variables are saved in the variables flyout when i create them (they persist), similarly i would want a composite block to be a user defined block that gets created on the click of a button and that persists or gets saved in the 'composite blocks' flyout to be used/reused in the workspace.
With functions, though i achieve the objective of clubbing multiple blocks within a single block, but the function block is just like any other loop block(for example) in that it does not get saved in the toolbox flyout. and cannot be created as and when the user wants to.
But i really appreciate you mentioning it. I will look into it more.