c# - Why don't lambda functions introduce similar issues as goto statements? -
in c# book reads, "the => lambda operator (read 'goes to')."
i've been wondering while difference between goto , lambda expression in terms of coding practice. if goto's avoided due possibility of convoluted code, couldn't lambda expressions lead same issue? more generally, why highly encouraged use lambda functions, while highly discouraged using goto's? (i.e. have ok grasp of why goto's unpopular, why aren't lambda functions unpopular similar reasons?)
my guess lambda functions evaluate , return something, not know goto may go off do. @ least should make lambda functions easier test fall more in line ideas of organized, object-oriented code.
just because "read" => "goes to" not mean has old-school goto statements. different things. i've heard developers alternatively use phrases "yields", or "arrow" when read symbol aloud.
a goto statement gives developers freedom move execution point arbitrary point in code. tends introduce bugs because it's hard developers keep track of possible states various variables might in @ given point in time, when execution able jump around arbitrarily.
all functions (including lambda functions) have defined scopes , execution flow follows logic established rest of c# language. remember lambda syntax "syntax sugar" maps delegate/closure, glorified function.
Comments
Post a Comment