switch to room list switch to menu My folders
Go to page: First ... 52 53 54 55 [56] 57 58 59 60 ... Last
[#] Tue Apr 13 2010 12:17:11 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

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.

[#] Tue Apr 13 2010 12:49:25 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

So, are "inner classes" and "nested functions" the same thing? Roughly?

[#] Tue Apr 13 2010 13:20:48 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

You mean the GNU C trampoline-based nested function extension? Approximately the same thing, yes. They both inherit scope in a similar way.

[#] Tue Apr 13 2010 14:25:32 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I thought those were incredibly useful, especially when dealing with things like callbacks in a multithreaded environment where globals can't be used and the only alternative is to pass gigantic structs full of crap back and forth. I was disappointed to discover that it's GNU-specific and nonportable.

[#] Tue Apr 13 2010 14:45:18 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Yeah, even UCSD Pascal had nested functions...


[#] Tue Apr 13 2010 17:44:11 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

It did, but I seem to remember being told that they were not reentrant.

[#] Tue Apr 13 2010 17:52:22 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

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...

[#] Tue Apr 13 2010 17:56:21 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

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.

[#] Wed Apr 14 2010 18:55:36 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

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.

[#] Thu Apr 15 2010 13:41:32 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Don't use enough closures.... erm... Well I agree with you on the cut and paste thing, and yeah, if they do that they should be smacked around, but maybe the better angle is to explain why cut and paste is bad instead of why closures are good, and let them work out what the best way to restructure their code is to achieve the goal. Certainly offer the closure suggestion, but to make that the point would be to miss the actual problem I think.

[#] Thu Apr 15 2010 16:56:43 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

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.

[#] Thu Apr 15 2010 21:24:03 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I guess I made certain assumptions about your coworkers I should not have.

[#] Tue Apr 20 2010 14:52:10 EDT from Spell Binder @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I think I've been reading up on Haskell too much lately.

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!
Monad Binder

[#] Tue Apr 20 2010 17:57:01 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Binder, the typesafe enum pattern might accomplish the same thing.

[#] Tue Apr 20 2010 17:58:16 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Good talk on how to code for multicore / parallelism. (GLS, of course, ends up asserting that LISP/Scheme hackers were right all along ;)


[#] Tue Apr 20 2010 18:08:51 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

ends up asserting that LISP/Scheme hackers were right all along ;)

Err, I mean, expect for that whole pesky linked list thing...


[#] Wed Apr 21 2010 10:13:23 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Sa Apr 10 2010 07:55:21 EDT von dothebart @ Uncensored

funky shit:




100KB limit in firefox browser only:

form enctype="multipart/form-data" action="uploads.php" method="POST"

No Limit:

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.

[#] Wed Apr 21 2010 12:13:07 EDT from Spell Binder @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

LS: Re: typesafe enum pattern matching.

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.
Monad Binder

[#] Wed Apr 21 2010 14:20:31 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Ohh, that sounds like an exception throw. Or a continuation.

Implementing first-class continuations in TCL would be a trip ;)

[#] Wed Apr 21 2010 14:56:03 EDT from Spell Binder @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Apparently, some of the TCL gurus have already been discussing that:

Go to page: First ... 52 53 54 55 [56] 57 58 59 60 ... Last