- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This is another good reason; and thanks for the hint, by the way!
Admin
(hint: "Object" is Java, "object" isn't)
Admin
Admin
Wouldn't an array created on the stack inside of a function fall out of scope when the function's stack frame is popped (at the time of its return)? Or is that the point you were making?
I'm not being rude, just ignorant. :)
Admin
The real WTF is that the Java guy uses arrays when the Collections framework is clearly much superior
Captcha: oppeto
Admin
Duh! I hope you guys are being sarcastic with this solution.... You do realize that it would require the developer to KNOW array syntax in order to create the parameter array which defeats the whole purpose
Admin
Unless I'm mistaken, the new operator allocates memory on the heap. I was under the impression that this was the whole point of the new operator in c++?
Admin
Admin
I hope you're being sarcastic, because otherwise it would mean you don't know what the "params" keyword means.
Admin
I can also imagine it exists for compatibility with ancient browsers that are no longer in use. Atlas has been around for quite awhile-- given the right userAgent, that might serve up a workaround for document.write not being present.
Admin
I can understand how arrays and square brackets are hard when you are half baked and running on empty from the monster gaming session the night before. Best to get these things peered reviewed before sending it out live. Unless of course the peer reviewers were the ones you were gaming with all night.
Admin
Admin
This is correct. I can confirm because we built the same thing at DoubleClick. My guess is that Atlas stole it from us.
Admin
These code samples remind me of some incredibly brilliant code I saw in a C++ library. However, it doesn't qualify as a WTF mainly because it is one of the best-known C++ libraries in one of the best-known C++ library sets, so it's gotta be good:
http://www.boost.org/doc/libs/1_41_0/boost/bind/bind.hpp
Tags: TRWTF is C++
Admin
Exactly.
Admin
As everyone already said: Use of params would chop that code down to size. Although, it really shouldn't be needed, since parameters arrays are infact, arrays. captcha: "uxor", as in "u haxor".
Admin
Wow. This, right here, is TRWTF for today.
You can all go home now.
Admin
That sir is the core of the Javascript. All other Javascript functionality originates in that one portion of the code. How it does, no one knows. It is not our place to inquire on the origin of the Javascript, we are mere mortals who use it as our tool.
Admin
Still doesn't do complex partitioning of the world into stack and heap, which was my real point. Of real languages that are in extensive use today, only C and C++ (plus assembler, of course, though there's no real need to have either heap or stack there) split the world of values into heap and stack. C is known to be low-level and has its strong niche there, but C++ is an odd beast that tries to be all things to all men (and in so doing, fails; languages are defined by their restrictions and omissions).
Admin
so, if someone forgets syntax, they print it out and stick it to your wall? Does that help them?
Admin
Admin
Hey, look. Slashdot is running a story right now about how Eolas's previous victory convinced them that it's time to sue everyone on the planet.
Admin
Isn't it obvious why he's creating array objects through functions like that? It's because of the editors. Most of the editors out there, if you want to create an array and you don't know the syntax, you're kind of screwed. You'd have to call up MSDN documation or something to figure it out. But if you create a single function that does it for you, then remember the name, when you type in the name IN THE EDITOR, it will instantly provide the syntax for you to work with the function.
I've done this stuff before and it makes everything SOOOOO much easier! When you've used 20-30 different languages in a professional environment over the past 15 years, it can get a little tricky trying to remember the exact syntax without a little assistance.
Admin
So Anonymous.....this ought to be interesting.....are you suggesting that the hundreds of thousands of Internet advertisers out there (we're pretty much talking every business on the planet) should not try to measure the success of their own advertising? Are we supposed to just start shooting blind?
FYI, it was companies like DoubleClick that brought about the success of the Internet by increasing advertising success exponentionally! Trust me, without DoubleClick, GOOGLE WOULD NOT EXIST TODAY! Google's business model today can be traced to online advertising models created by companies like DoubleClick. In fact, in the first few years before Google switched over to the PPC model, they were considered to be somewhat of a failure (that whole necessity to earn a profit thing is a real bitch). Like tens of thousands of other companies, Google finally realized that offering everything for free won't make you any money.
Everybody that earns a living on the Web owes their careers to DoubleClick, Overture, and a handful of other pioneering companies.
Admin
Admin
This isn't true, at all.
In C#, there are "reference-types" which are stored on the heap. These are objects, and primitives created with the new keyword.
There are also "value-types" which are stored on the stack. This would be things like primitives (int, string, etc), as well as the variables that reference objects on the heap.
Value-types are destroyed when their stack frame is popped (thereby giving us scope). Reference-types are garbage collected at some point after there are no more references to them on the stack.
The differentiation between the stack and heap is still important in C#.
Admin
Arrays (System.Array) are always value types. The stack is irrelevant.
Admin
reference types.
FTFM
Admin
Agreed. As well as proxying for debugging and compression, you could change the meaning entirely if attempting a refactor, or something similar.
function DocumentDotWrite(t){ $('#myDiv').append(t) };
for example.
Admin
I think the only thing on the stack is a pointer...
Admin
the array is just 16sizeof(int) bytes on the stack (the address of array[0] is also put on the stack, so it's 16sizeof(int)+sizeof(int*) bytes in total). It would be the same - with different size - for larger arrays, and if you have a compiler which supports it, also for variable-length arrays. Be careful not to cause a stack overflow.
Admin
In JavaScript you can do document.write=function(t){$('#myDiv').append(t)} because it is the most flexible programming language now.
Admin
the javascript looks like it may be shockwave /flash load hack of some sort. Drill into the codesearch:
Code search
I don't really want to make this longer ... sometimes being succinct gets you minus points with akismet ;(
Admin
Well, except that in JS you could do something like:
var foo = document.write; document.write = function(str) { doSomeLoggingOrDebugging(str); foo(str); }
I don't want to call this a generally good idea but way better than writing a wrapper funcion in case you ever might want to add something to a core method.
Admin
That's correct. You also need to call document.write() from an external script as well - it's part of the workaround for the patent.
The problem here is that the developer didn't leave a comment explaining WTF is going on.
Admin
And that would be a good thing. Before the advertisers, the Internet was actually full of useful information.
Now it's full of facebooks and fashion blogs and whatnot. DoubleClick ruined the internet.
NOW GET OFF MY LAWN!!!
Admin
It's called overloading, not polymorphism.
Admin
May have been said before, but hooking document.write for debugging or logging can easily be done by a wrapper function like
document.prototype.baseWrite = document.prototype.write;
document.prototype.write = function(arg) { if(document.loggingEnabled) { logCall(); doOtherStuff(); } document.baseWrite(arg); }
or something
Admin
(2) document.write() doesn't work like that. It can only be used while the page is loading, and writes to the layout of the page where the script was called. Calling it from an external script wouldn't work unless a script on the page called the external script while the page was loading - when it could have just as easily called document.write().
What you are thinking of - appending something to the page after it's done loading - could be accomplished with something more like,
or, if you want to set some attributes, Really, there's still no good reason why the code couldn't just call document.write()... and if it's really due to some lawsuit stupidity that it has to be done with an external script, why not leave an empty space and then have the external script properly create and insert an Object node of the appropriate type? Using document.write() is a WTF all by itself. An external script containing nothing but a wrapper for document.write() is stupid. The prototype is Document.prototype, not document.prototype (Javascript is case-sensitive). Furthermore, Document.prototype.write doesn't exist, and defining it has no effect on document.write(). You meant,Admin
pharmacie en ligne fiable http://kamagraenligne.com/# pharmacie en ligne france livraison internationale