Content deleted Content added
m Signing comment by Evildeathmath - "→On ECMAScript examples: " |
|||
Line 361:
::::::: It should be noted that you're effectively doing the same thing from the other end, by restricting your clients to a subset of the language when writing closures, by not giving them the same convenience they get when writing top-level methods (since they cannot return from the middle of the closure to the outer scope anymore). This stems from the fact that closures are simply not the right tool for the job - what you need to emulate control structures is blocks, [http://innig.net/software/ruby/closures-in-ruby.rb Ruby-style]. That way you get a structure which does not "rebind" return and other similar keywords from the outer scope, but that cannot outlive the scope it was created in either (so there's no possibility that it will be called when there's nothing to return from anymore), thus not a true closure. Well, in Ruby you can cheat your way around it, but at least you have to do that explicitly (by <code>proc</code>'ifying the block to an object). [[User:Int19h|-- int19h]] 05:39, 30 January 2007 (UTC)
::::::: The above JavaScript example is broken--it calls <code>ifcond()</code> twice, which if <code>ifcond()</code> alters any variables or calls any functions that alter anything, could result in incorrect state. Additionally, if something changes such that the second call to <code>ifcond()</code> does not return the same result as the first, both (or neither) of <code>ifblock()</code> and <code>elseblock()</code> could be evaluated. <small><span class="autosigned">—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:Evildeathmath|Evildeathmath]] ([[User talk:Evildeathmath|talk]] • [[Special:Contributions/Evildeathmath|contribs]]) 16:54, 17 December 2008 (UTC)</span></small><!-- Template:Unsigned --> <!--Autosigned by SineBot-->
::::: I would certainly like it if I could write my own control flow structures in JavaScript as I used to do in FORTH. But you won't convince me, or any other experienced JavaScript programmer, that the language lacks closures. Ain't gonna happen. Sorry! :-) I've often heard the phrase "dictionaries are descriptive, not prescriptive." Doesn't the same principle apply to encyclopedias? --[[User:Geary|Michael Geary]] 08:13, 29 January 2007 (UTC)
|