Python has a built-in variable __debug__ which is set to True when python is called without -O (optimize). The -O flag disables all assertion code.
This seems at first glance like a very easy and clean construct to rely on when coding in development versus production: in development, don't use -O, defensively litter your code with type- and sanity-checking asserts. Perform development-only debugging by testing __debug__ beforehand.
When in production, run all code is run with -O which disables asserts (speeding execution) and sets __debug__ to False.
Why is this construct not more popular? Why does nearly large-ish collection of python code re-invent a DEBUG global variable or the like and ignore __debug__?
Reading http://en.wikipedia.org/wiki/Scheme_(programming_language)
- Why the necessity for
let
,let*
, andletrec
? It seems likelet*
would do everything thatlet
can do; andletrec
can do everythinglet*
can do. If it is a matter of performance (islet
simpler and faster thanletrec
?) then could a clever interpreter determine which of the three was appropriate for any given set of definitions?
Reading http://blog.moryton.net/2007/12/computer-revolution-hasnt-happened-yet.html
- Can the "big wins" from smalltalk exist separately from some of its unusual features like
- image-based persistence
- a built-in graphics environment with (non-tiling) window manager, (crappy) code editor, and (interesting) code browser?
- (yes, because some lisps have this image-based computing idea, and some do not?)
- How does one test, package & distribute small units of smalltalk code?
- Specifically about image-based persistence:
- Doesn't a crash run the risk of massive loss of state? (read up about image-based persistence)
- Doesn't the assumption of modifying the code on a long-running vm risk corrupting the state? How does one rollback/recover?
- Examine http://stackoverflow.com/questions/722204/which-programming-languages-besides-smalltalk-are-image-based
- Long-running stateful seems more vulnerable to memory leak issues and less compatible with "ephemeral" virtual hosting. False?
- Specifically about SmallTalk's (Squeak's?) built-in graphical development environment:
- Graphical development environment as desktop environment? As operating system?
- The whizzy features of being able to interact with rotated UI elements in real-time feels slow. Can the VM take advantage of accelerated graphics libraries like OpenGL?
First, the stuff I kind of know something about.
let
,let*
, andletrec
are largely due to implementation concerns.let
forms to be evaluated in parallel, as opposed tolet*
which has an explicit data-dependent ordering. I am unaware of compilers that take advantage of this but there may be some.letrec
allows for definition of recursive and mutually-recursive functions. This is quite different at the assembly/IR level thanlet
andlet*
, of course. While a sufficiently smart compiler could disambiguate a more generallet
construct (and that compiler is probably GHC) there was sufficient precedent in both the Lisp and ML communities for this to never be a big pain point for most people. The specs have much bigger problems, Common Lisp especially. ;)