Syntactic sugar: a language construct, implemented by a compiler, which acts as a sort of shorthand for an equivalent, but more verbose, piece of syntax that can be implemented in the same language and would compile to the samsame object code. LISP and Scheme compilers, for example, often have a first pass that performs "desugaring" by transforming certain high-level constructs into their lower-level LISP/Scheme equivalents.
Java inner classes are essentially syntactic sugar for a specific pattern of regular class usage. (Inner classes are more than just namespaces: they inherit all variables in their lexical scope, including members of the constructing outer class instance, and, for anonymous inner classes, variables on the stack of the constructing method.)
But those stack variables have to be "final" (same as "const") which allows the compiler to implement all of this as syntactic sugar for outer classes: any variable that the inner class needs to inherit from its enclosing lexical scope, will simply become an implicit constructor parameter.
So the purpose is more than just to restrict scope. The key feature is the inheritance of variables defined in the enclosing lexical scope.
You mean the GNU C trampoline-based nested function extension? Approximately the same thing, yes. They both inherit scope in a similar way.
Yeah, even UCSD Pascal had nested functions...
I don't remember whether they were reentrant in that sense.
PHP 5.3 now has closures, and one of the Java closures proposals looks a lot like Haskell.
PHP's closures are not quite the same animals are Java's are going to be; Java is going to have a transparent conversion between "interfaces that only implement one function" and "function"
Assuming the proposal doesn't get rejected again...
all this rambling aside, part of my job description at $employer now entails teaching a class or two. Not the way I want it, but if I want to get even a "C" on my own report card, that's what I gotta do.
Right now my main motivation is I don't think our people use enough closures (nested functions, lambdas, inner classes, callbacks, whatever you want to call them) and I need to put together some examples to motivate that development style.
It's basically the silver bullet for code reuse... eliminates all that cut/paste stuff.
of crap back and forth. I was disappointed to discover that it's
GNU-specific and nonportable.
Probably exists at all because RMS had a LISP background.
Hmm, erm, everyone already knows that cut'n'paste is bad, mmkay, so I don't want to sound like I'm on a South Park episode, which would be bad, mm'kay? It's just that not everyone is motivated to do anything about it, and although I don't want to be seen as talking down to other people who did take CS in college after all thank you very much, we have a lot of PHP guys here who tend to say things like, "I haven't done any Java in a while..."
Maybe what I need is an entirely different topic to steer clear of the whole debate. Spring Framework.
I just had to patch a TCL script that detects warning or error messages in the output of a command. While testing my patch, I thought to myself, "Hey, I could define an enumerated algebraic type for this and then write a monad to parse the command output."
Which would make the code much more flexible if we ever had to look for a different error condition, but, this code hasn't changed in years and it would be a huge undertaking as I'd have to implement monads in TCL!
Binder, the typesafe enum pattern might accomplish the same thing.
Good talk on how to code for multicore / parallelism. (GLS, of course, ends up asserting that LISP/Scheme hackers were right all along ;)
ends up asserting that LISP/Scheme hackers were right all along ;)
Err, I mean, expect for that whole pesky linked list thing...
Sa Apr 10 2010 07:55:21 EDT von dothebart @ Uncensored
100KB limit in firefox browser only:
form enctype="multipart/form-data" action="uploads.php" method="POST"
form enctype="multipart/form-data" method="POST" action="uploads.php"
Btw, at least webcits message editor wasn't fixed to upload larger chunks than 20MB. Didn't check the files rooms yet... so swapping the arguments makes it a little better, but doesn't Heal it as described in that forum.
I'm not sure I follow you. The reason I thought of a monad was because this particular TCL script looks for a specific set of messages, but it reacts differently to different messages. In some cases, it makes note of the message it found, but continues to look for more. In other cases, as soon as it detects a specific kind of message, it needs to bail out. That kind of behavior sounded very much like Haskell's Maybe monad, where, if any computation results in Nothing, the entire chain of computation returns Nothing.
Ohh, that sounds like an exception throw. Or a continuation.
Implementing first-class continuations in TCL would be a trip ;)