Greg Ewing writes:

 > You've probably never seen the one I'm thinking of. It's a
 > proprietary, vaguely VB-like language used for scripting a
 > particular application. It doesn't work like Lua, but it
 > does have scoping rules that can lead to some surprising
 > results.

By contrast, Lisps (at least Lisp2s like Emacs Lisp and Steel Bank
Common Lisp) have #'makunbound, and this is an unbound symbol error in
both:

(defvar x 1)
(defvar result '())
(let ((x 2))
  (push x result)
  (makunbound 'x)
  (push x result)    # error is signaled here
  result)

Since Common Lisp is the world's most overengineered language, I would
guess this scoping rule is deliberate.

 > One particularly weird thing it does: if you don't declare
 > a variable (it has optional declarations) it will *usually*
 > infer it to be local if you assign to it. But if the first
 > assignment is in a conditional branch of the code, it seems
 > to get confused. If you do this:
 > 

 >      if something then
 >          x = 5
 >      else
 >          x = 7
 >      end if
 > 
 > and later refer to x, it complains that x hasn't been defined.
 > Go figure.

Some versions of GCC would occasionally complain that "x might be used
uninitialized" in similar code in C, too.  Spent a lot of time on such
warnings, sometimes GCC was right, but sometimes it just didn't make
sense.  Apparently compiling such code, at least with optimization,
can be hard.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7Y2C5HKYCOUGG3JAAPXEIUGH2JM7AO3T/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to