function createProcDefBlock(
  workspace,
  hasReturn = false,
  args = [],
  name = 'proc name',
) {
  return Blockly.serialization.blocks.append(
    {
      type: hasReturn ? 'procedures_defreturn' : 'procedures_defnoreturn',
      fields: {
        NAME: name,
      },
      extraState: {
        params: args.map((a) => ({name: a})),
      },
    },
    workspace,
  );
}
Creates procedure definition block using domToBlock call.
@param {!Blockly.Workspace} workspace The Blockly workspace.
@param {boolean=} hasReturn Whether the procedure definition should have
   return.
@param {Array<string>=} args An array of argument names.
@param {string=} name The name of the def block (defaults to 'proc name').
@returns {Blockly.Block} The created block.