Re:Actually, you don't understand lexical scope
by run4yourlives on Monday September 17, 2012 @07:34PM
(#4535455)
Can we just implement Python (or anything else, really, hell I'll even take VB at this point) in the browser already and get rid of this monstrosity of a language? Please?
[ Parent
| on HN ]
Re:Actually, you don't understand lexical scope
by mistercow on Monday September 17, 2012 @08:05PM
(#4535551)
Really? Python's handling of reaching into the outer scope of a function is just as confusing (although I hear it is fixed in 3000?).
Python used to be my favorite language, but I'm currently working on a project that is CoffeeScript on the client and Python on the server, so I'm getting plenty of time to compare them side by side. It would be difficult to overstate how much I prefer working with CoffeeScript.
The thing is, this scope situation, which is admittedly not as elegant as it could be, is really a rare situation to run into. If it happens to you often, it generally means that you need to give your more global variables less vague names.
Re:Actually, you don't understand lexical scope
by jrockway on Monday September 17, 2012 @09:33PM
(#4535818)
Really? Python's handling of reaching into the outer scope of a function is just as confusing (although I hear it is fixed in 3000?)
Do you mean:
try:
foo = '42'
except Whatever:
raise
print "foo is %s" % foo
If so, I really like that feature. It's much clearer to me than what I'd write in another language: foo = None
try:
foo = 42
...
Re:Actually, you don't understand lexical scope
by ostso on Monday September 17, 2012 @10:11PM
(#4535931)
Perhaps mistercow means things like
def foo():
x = 5
def bar():
print x
def baz():
x = 6
print x
bar()
baz()
print x
Which prints 5, 6, 5. If baz tried to print x before assigning, it would be an UnboundLocalError.
Re:Actually, you don't understand lexical scope
by lvh on Tuesday September 18, 2012 @05:05AM
(#4537069)
I believe you are referring to the nonlocal keyword, which means that unlike the regular case (assignment binds as locally as possible), assignment will bind where the name is bound now. (There's a third case for globals, but let's not talk about those.)
Re:Actually, you don't understand lexical scope
by lihaoyi on Monday September 17, 2012 @08:39PM
(#4535661)
If we'd implement the JVM in the browser, we'd get Java as well as Jython/JRuby/Clojure/Scala almost for free.
Re:Actually, you don't understand lexical scope
by tesseractive on Monday September 17, 2012 @08:49PM
(#4535694)
Given that Oracle is now going around and suing companies that put Java to a use they don't approve of (see: the Google lawsuit over Dalvik), it appears that the JVM is too IP-encumbered to be a suitable candidate for a web standard.
Edit: imagine what a failure case it would be for the web if Oracle owned the IP rights to a core web standard and actively asserted them. Yikes.
Re:Actually, you don't understand lexical scope
by nostrademons on Monday September 17, 2012 @11:45PM
(#4536208)
It's been done before: