Closed GoogleCodeExporter closed 9 years ago
p.s. I hope the title is not rude or demanding.
If so: Sorry for that.
Original comment by borntob...@googlemail.com
on 8 Nov 2012 at 8:12
And it's me once again.
Another useful block is a block which returns the value 'null' :)
e.g. like:
Blockly.Language.null_ = {
category: Blockly.LANG_CATEGORY_X,
helpUrl: null,
init: function() {
this.setColour(Blockly.LANG_CATEGORY_X_COLOUR);
this.appendDummyInput().appendTitle('null');
this.setOutput(true,null);
this.setTooltip('Return null');
}
};
Python generated code:
Blockly.Python.null_ = function() {
return ['null',Blockly.Python.ORDER_NONE]; //check to which order category null belongs to?!
};
Original comment by borntob...@googlemail.com
on 8 Nov 2012 at 8:33
added in r508
Original comment by gasolin
on 13 Nov 2012 at 3:02
Since "null" doesn't have much to do with procedures, I've moved this block to
the logic category. (r509)
With respect to "return", I searched through hundreds of thousands of lines of
code at Google and found that in virtually all cases where return is used
before the end of a function (i.e. not the last line), the return is wrapped in
an if statement. This is known as a "guard clause":
http://c2.com/cgi/wiki?GuardClause
Accordingly, I have replaced the "return" block with an "if-return" block. It
also warns if it is not enclosed in a procedure, and it automatically mutates
to have (or not have) a return value depending on the enclosing procedure.
(r511)
Original comment by neil.fra...@gmail.com
on 17 Nov 2012 at 11:49
Original issue reported on code.google.com by
borntob...@googlemail.com
on 8 Nov 2012 at 8:11