Language:
switch to room list switch to menu My folders
Go to page: First ... 64 65 66 67 [68] 69 70 71 72 ... Last
[#] Sat Aug 21 2010 05:29:06 EDT from Nite*Star @ Uncensored

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

Perl? PHP?

[#] Sat Aug 21 2010 11:42:57 EDT from IGnatius T Foobar @ Uncensored

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

if (!(cpl.runkey_on = cpl.runkey_on ? FALSE : TRUE))

Can you explain it to me? :/ 'cuz I don't know what it says.

Well, the first thing it would do is assign cpl.runkey_on to the value of itself, which of course accomplishes nothing, but the value returned by that expression is whatever that variable's value was in the first place.

Then this expression: xxx ? FALSE : TRUE returns FALSE if the expression is true, and TRUE if the expression is false. Assuming that FALSE is set to zero and TRUE is set to nonzero, this would have the effect of negating the expression.

Then this expression: !(x) negates it again.

So the whole thing could have been written as:

if (cpl.runkey_on)

This indicates that either this code is several generations old and someone did a really bad job reducing out code that was no longer needed, or (far more likely) someone was just being obnoxious and wrote deliberately obfuscated code.

[#] Sun Aug 22 2010 13:41:14 EDT from Ford II @ Uncensored

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

if (!(cpl.runkey_on = cpl.runkey_on ? FALSE : TRUE))

It toggles the value of cpl.runkey_on and then returns the opposite, thus the original value to the if statement.

[#] Sun Aug 22 2010 13:42:25 EDT from Ford II @ Uncensored

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

I think the purpose is to operate on the current value of runkey_on and then toggle it, which is basially what it does.

[#] Sun Aug 22 2010 13:45:15 EDT from Ford II @ Uncensored

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

#include <stdio.h>
#include <stdlib.h>

int main(int num, char *opts[])
{
int x = 1;
int y;
y = (!(x = x? 0 : 1));
printf ("x = %d, y = %d\n", x, y);
y = (!(x = x? 0 : 1));
printf ("x = %d, y = %d\n", x, y);
y = (!(x = x? 0 : 1));
printf ("x = %d, y = %d\n", x, y);
y = (!(x = x? 0 : 1));
printf ("x = %d, y = %d\n", x, y);
y = (!(x = x? 0 : 1));
printf ("x = %d, y = %d\n", x, y);
y = (!(x = x? 0 : 1));
printf ("x = %d, y = %d\n", x, y);
return 0;
}

[#] Sun Aug 22 2010 13:45:29 EDT from Ford II @ Uncensored

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

you'll see that x and y toggle and are opposite each other.

[#] Sun Aug 22 2010 16:37:45 EDT from LoanShark @ Uncensored

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

What do all of you developer types think is the 'best' embeddable
scripting extension language?  (Open source candidates only,
please.)

I'd lean toward Python or Ruby, if your target is something lightweight and interpreted, but not necessarily blazing high performance. Perl is a non-starter because it's picked up too much cruft over the years.

[#] Sun Aug 22 2010 16:50:04 EDT from LoanShark @ Uncensored

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

Aug 21 2010 5:29am from Nite*Star @uncnsrd
Perl? PHP?



PHP is not really a solid platform for development. Too much undefined or poorly defined semantics (take a look at == vs === and the handling of null.) It's quite slow. It has binary compatibility issues with Apache and Oracle. It has source compatibility issues with previous versions of itself. Also, I don't see how a web templating language meets IG's requirements.

[#] Sun Aug 22 2010 16:54:08 EDT from LoanShark @ Uncensored

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

So the whole thing could have been written as:

if (cpl.runkey_on)

You've got that backwards. the ternary operator has higher precedence, so Nite*Star's example is a flip-and-test operation, just poorly written.

[#] Sun Aug 22 2010 16:58:41 EDT from LoanShark @ Uncensored

Subject: Re:

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

Uh, JavaScript is Scheme in C's clothing. Python is Lisp , except
it's very slow. Lua is nice too, but a bit slow.

Uh, no. Last I checked, JavaScript didn't have hygienic macros or first-class continuations.


Also, it has syntax. Scheme has no syntax[1], only parentheses.

[1] http://www-mitpress.mit.edu/sicp/full-text/book/book.html

[#] Sun Aug 22 2010 23:17:40 EDT from Animal @ Uncensored

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

Maybe used as a signal for an event case somewhere?

dunno... that's all i got

[#] Thu Aug 26 2010 12:15:28 EDT from LoanShark @ Uncensored

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


Duly noted.

[#] Thu Aug 26 2010 14:00:10 EDT from Spell Binder @ Uncensored

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

Hey, at least he's honest. :)

[#] Thu Aug 26 2010 15:19:11 EDT from Ford II @ Uncensored

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

final String pig = "length: 10";
final String dog = "length: " + pig.length();

I wouldn't even make the assumption that pig == dog if dog was defined as "length: 10".
Maybe there's some java spec that guaranetees that identical final strings will yield the same object, but I wouldn't rely on that, for the same reason I don't rely on short ccircut boolean expressions: c++. :-)

[#] Thu Aug 26 2010 15:24:14 EDT from Ford II @ Uncensored

Subject: Re:

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

I don't know what you just said, but ok.

Don't worry, a lot of people have that problem, it's part of the rite of passage of being able to play ball in this room.
I understand maybe 95-98% of what he says most of the time and Ihave to read 2 paragraphs of wikipedia to get the rest. :-)

[#] Thu Aug 26 2010 15:25:32 EDT from Ford II @ Uncensored

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

I wouldn't even make the assumption that pig == dog if dog was
defined as "length: 10".

which by the way, I just tried and it's still not equal

This however
System.out.println("A" == "A");

prints true. Go figure.

[#] Thu Aug 26 2010 15:29:41 EDT from Ford II @ Uncensored

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

...and you can stop laughing, even my dad was surprised that I knew exactly zero of the precedence rules, because I just use parenthesis, and that works every single time.

[#] Thu Aug 26 2010 15:40:28 EDT from IGnatius T Foobar @ Uncensored

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

A parenthesis works? I'm surprised it even compiles. Most languages require that parentheses are used in pairs.

[#] Thu Aug 26 2010 15:40:45 EDT from IGnatius T Foobar @ Uncensored

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

(damn that was pedantic, even for me <grin>)

[#] Thu Aug 26 2010 18:28:56 EDT from LoanShark @ Uncensored

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


Seriously. Ford you should just code in Scheme, clearly you'd be happier...


So yes, the example was a precedence thing, but it actually contained two different bugs, one was == vs .equals and the other was precedence.

So "A" == "A" returns true only by accident, because the compiler optimized it such that there is only one object instance created.

So, in the example, pig == dog is false, but pig.intern() == dog.intern() would be true, but it's a bad idea to ever call .intern() in a production program.


This example and many more can be shamelessly stolen from Neal Gafter's excellent book, titled something like Java Puzzlers : traps and pitfalls

Go to page: First ... 64 65 66 67 [68] 69 70 71 72 ... Last