Movatterモバイル変換


[0]ホーム

URL:


Named code blockes

Alex Martellialeaxit at yahoo.com
Sun Apr 15 03:07:15 EDT 2001


"Steven D. Majewski" <sdm7g at Virginia.EDU> writes:> Typically, a named block has the name label at the top -- which is> not usually where the control is flowing to, and you have to huntRight: it's where the control is _breaking away from_ (for a break;it IS, in fact, "where it's flowing to" for a continue).  Note that thisis even more obvious for the make-it-a-function alternative: returnclearly shows what (function) you are EXITING from, but NEVER'where the control is flowing to' -- it flows to wherever it needs to,that's not the point -- the point is terminating a conceptual unit(and a named loop is as much as a conceptual unit as a function:if it's code needs to occur exactly once, having it lexically inlineat the single point of occurrence is a plus!).> and peek around to find the next executable statement. What's clear> and explicit about that ?A good part is in the name.    break eggs_searchYou don't need context to see that this is terminating the 'searchfor eggs' named conceptual unit.  "what happens next" ("wherethe control is flowing to") is obviously "whatever's next aftersearching for eggs", just as if this was a function named that waywith a return statement here == indeed, the lexical situation interms of "let me look for where this goes now" is easier than for function calls, where it's generally anything but clear at a firstglance that a certain function is called from just one place, andwhere that place is.> A restricted use of GOTO is more (IMHO) clear.MHO differs.  I don't want to think of this-then-that-then-the-other control flow in a VHLL, I want to think of named buildingblocks and their nesting and entering and exiting.> try/except blocks come in somewhere in between Goto and named> blocks for readability. Not a bad compromise if you don't want> to rely on disciplined use of goto. The target is pretty clear.It's lexically constrained, but lacks a name, which is a strongconceptual help (the name of the exception you raise can help,but that should be the reason for exiting, not WHAT you areexiting).> ( But maybe you're thinking of a different syntax for Python>   than I can imagine from other lang. I've seen. If you show>   me a clear example, I'll reconsider. )Nope, I had in mind the same kind of syntax seen in otherlanguages, sugary issues apart (it's minor from my POV whethernaming a loop involves using 'as', a colon, or whatever) -- beingable to name a block and to mention that name in a break.Alex_________________________________________________________Do You Yahoo!?Get your free @yahoo.com address athttp://mail.yahoo.com


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp