Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
HIERARCHY OF WEEDZ
Aug 1, 2005

You know, it's so difficult to use an integer as an index on an array, we should just throw an eval around it instead.

code:
if(eval("document.frmFoo.optBar[" + idx + "].checked") == true) baz += 3;

Adbot
ADBOT LOVES YOU

1337JiveTurkey
Feb 17, 2005

shopvac4christ posted:

You know, it's so difficult to use an integer as an index on an array, we should just throw an eval around it instead.

code:
if(eval("document.frmFoo.optBar[" + idx + "].checked") == true) baz += 3;

If that wasn't autogenerated, there is no God.

HIERARCHY OF WEEDZ
Aug 1, 2005

1337JiveTurkey posted:

If that wasn't autogenerated, there is no God.

Well, prepare to have nowhere to go when you die.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

shopvac4christ posted:

Well, prepare to have nowhere to go when you die.

I remember playing in mIRC scripting. There are no arrays in this language (or weren't, yet).

So if I wanted to have, say, an array of players, my best method was

$[player. [ $+ [ $num ] ] ]

Things got worse before they had hashes. If I wanted to load a player's stats into a location...

$[player. [ $+ [ $num ] $+ ] .attack]

I wrote an entire game in this "language".

:suicide:

(I'll try to pull out some examples when I get home.)

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

shopvac4christ posted:

You know, it's so difficult to use an integer as an index on an array, we should just throw an eval around it instead.

code:
if(eval("document.frmFoo.optBar[" + idx + "].checked") == true) baz += 3;

At least there's a variable involved. I recently had the joy of working with code full of this:
code:
eval("if (document.form1.textField.value == '') document.form1.textField.value = 5;");
I never did figure out what the point of the eval was. I assume it was someone who knew no javascript copying and pasting code written by someone who knew very little javascript and used eval instead of document.form1[fieldName] or document.getElementsByName.

jarito
Aug 26, 2003

Biscuit Hider
Here is one from my work:

code:
int transactionSetControl = int.Parse(SystemSettingService.SystemTransactionSetControlNumber);
transactionSetControl++;
string transactionSetControlString = transactionSetControl.ToString();

while (transactionSetControlString.Length < 4)
    transactionSetControlString = "0" + transactionSetControlString;
Issues:
1. TransactionControlNumber stored as a string.
2. Uses a while loop to pad the number.

:sigh:

Lexical Unit
Sep 16, 2003

I started working on a new project yesterday so I was reading some of the code trying to get a feel for how things are organized. I noticed two files called DirectoryFileObjects.h and two files called DirectoryFileObjects.cc. I diffed each pair to see what was up, they were the same. So I went into the revision tool and what I see is that one of them is an original and the other is just a copy that is kept in sync with changes made to the original.

Like, the revision comments on one of the pair of files is something like:
- added blah support

And then the revision comments on the other file (for the same change) is:
- synced with master

Why? Because the developer needed some of the functions defined in DirectoryFileObjects.h, but he needed them somewhere else than where the original DirectoryFileObjects.h exists. :psyduck:


And that's not mentioning the 2345 line function in DirectoryFileObjects.cc whose last 14 lines are nothing but closing braces stepping down 14 levels of indentation. :bravo:

Teabiscuit
Jul 21, 2005

by T. Finninho
My housemate does horrible things with variable names. His code often looks like this
code:
if (rapefucker1 == cockstick)
{
  for (int SHITCOCK = 0,sodomy > 20,SHITCOCK++)
  {
    ANALRAPE = CUNTBAGS;
    sodomy += ANALRAPE;
    if (sodomy != CUNTFINGERS)
    {
       sodomy = Dicklegs->dropthecunt(sodomy);
    }
  }
}
Sometimes i ask him what certain variables are doing and he says he has no idea but if he takes it out the program breaks.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Teabiscuit posted:

My housemate does horrible things with variable names. His code often looks like this
code:
if (rapefucker1 == cockstick)
{
  for (int SHITCOCK = 0,sodomy > 20,SHITCOCK++)
  {
    ANALRAPE = CUNTBAGS;
    sodomy += ANALRAPE;
    if (sodomy != CUNTFINGERS)
    {
       sodomy = Dicklegs->dropthecunt(sodomy);
    }
  }
}
Sometimes i ask him what certain variables are doing and he says he has no idea but if he takes it out the program breaks.

This is hilarious.

BillWh0re
Aug 6, 2001


Teabiscuit posted:

My housemate does horrible things with variable names. His code often looks like this
code:
if (rapefucker1 == cockstick)
{
  for (int SHITCOCK = 0,sodomy > 20,SHITCOCK++)
  {
    ANALRAPE = CUNTBAGS;
    sodomy += ANALRAPE;
    if (sodomy != CUNTFINGERS)
    {
       sodomy = Dicklegs->dropthecunt(sodomy);
    }
  }
}
Sometimes i ask him what certain variables are doing and he says he has no idea but if he takes it out the program breaks.

Dotfuscator should work like this.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

ryanmfw posted:

Minus the social part, yeah. I didn't go to them to meet people. It was a lot more fun crushing their hopes and dreams....

Demented and sad, but social.

Jo
Jan 24, 2005

:allears:
Soiled Meat

Teabiscuit posted:

My housemate does horrible things with variable names. His code often looks like this
code:
  for (int SHITCOCK = 0,sodomy > 20,SHITCOCK++)
Sometimes i ask him what certain variables are doing and he says he has no idea but if he takes it out the program breaks.

Buy him an account here. Username: SHITCOCK++

ohgodwhat
Aug 6, 2005

rotor posted:

Demented and sad, but social.

Oh please, they all played WoW, so they thought they were good at computers with the associated egos. The one team gave up 30 minutes into it to play some flash version of DDR. :v:

Sergeant Rock
Apr 28, 2002

"... call the expert at kissing and stuff..."
It's from The Breakfast Club. Don't you forget about that film.

PrBacterio
Jul 19, 2000

Smackbilly posted:

Agreed. We don't need a full whacko APL keyboard, but it would be pretty nice to at least have characters for basic set operations (intersect, union, subset, superset), and a single glyph for -> on normal keyboards. I'd even be happy with settling for a bigraph for subset-or-equal and superset-or-equal.
Well I don't necessarily know about those, but I would very much welcome being able to use the proper glyphs, i.e. ≠, ≤ and ≥, for comparisons, instead of !=, <= and >=. (I'm also one of those people who'd prefer the Pascal-style syntax of = as the comparison operator with := being used for assignments, instead of the C-style == for a comparison operator...)

tef
May 30, 2004

-> some l-system crap ->

PrBacterio posted:

I'm also one of those people who'd prefer the Pascal-style syntax of = as the comparison operator with := being used for assignments, instead of the C-style == for a comparison operator...)

= is for unification :v:

(Which is a mixture of non-destructive asignment and equality, X=3 succeeds if X is unbound (so, x is set to 3) or X is already set to 3. )

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

PrBacterio posted:

Well I don't necessarily know about those, but I would very much welcome being able to use the proper glyphs, i.e. ≠, ≤ and ≥, for comparisons, instead of !=, <= and >=.

Sounds like you'd like Applescript! :v:

quote:

(I'm also one of those people who'd prefer the Pascal-style syntax of = as the comparison operator with := being used for assignments, instead of the C-style == for a comparison operator...)

The one true assignment operator is ← :colbert:

code:
int x &#8592; 5;
if (x = 5) printf("this will always run k");
In my ideal world, ← would be for assignment, = for equality (overloadable), and ≡ for identity (point to the same object/address in memory).

Jo
Jan 24, 2005

:allears:
Soiled Meat

Flobbster posted:

In my ideal world, ← would be for assignment, = for equality (overloadable), and ≡ for identity (point to the same object/address in memory).

If those were easily typable, I'd support your endeavor whole heartedly.

\/\/ Not working. :(

Jo fucked around with this message at 02:26 on Jul 7, 2008

TheSleeper
Feb 20, 2003

Jo posted:

If those were easily typable, I'd support your endeavor whole heartedly.

What, you have a problem typing alt+27 every time you want to assign to a variable?

PrBacterio
Jul 19, 2000

Jo posted:

If those were easily typable, I'd support your endeavor whole heartedly.
That'd work too, yes. Really I'm only bothered about that there already exists a perfectly good equality operator in '=', but because of some stupid historical accident most programming languages forego using it for some ugly hacks like '==' (and by now there's even worse horrors like '==='). Really, either an arrow or the good old-fashioned Pascal-style colon-equals would make for perfectly good assignment operators, I don't care.

Vanadium
Jan 8, 2005

But assignment is way more common than testing equality, so it deserves the shorter operator!

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Flobbster posted:

Sounds like you'd like Applescript! :v:
I'd like it too if Windows let you type extended characters as easily as MacOS does.

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

Vanadium posted:

But assignment is way more common than testing equality, so it deserves the shorter operator!

Also it has the same length as <=, >= and != which appeals to the symmetry-loving.

zootm
Aug 8, 2006

We used to be better friends.
I remember catching this one time in production C# code at an old job:

code:
try
{
    // Code here...
}
catch( Exception )
{
    int i = 0;
}
The explanation for this craziness was "I needed to put a breakpoint there". Gah.

HicRic
Dec 4, 2006
To disagree with three-fourths of the British public is one of the first requisites of sanity.

zootm posted:

I remember catching this one time in production C# code at an old job:

code:
try
{
    // Code here...
}
catch( Exception )
{
    int i = 0;
}
The explanation for this craziness was "I needed to put a breakpoint there". Gah.

Actually, I'm guilty of doing this sometimes, but I always remove it afterwards. (hell, I even use the exact same "int i = 0"!) Is there a more correct way?

ehnus
Apr 16, 2003

Now you're thinking with portals!
In C# you can use System.Diagnostics.Debugger.Break(). C/C++ often have platform-specific ways of triggering a debug break point, and on PCs there's always interrupt 3. I'm not sure about other languages but they often have their own ways of breaking into the debugger

zootm
Aug 8, 2006

We used to be better friends.
In most Java debuggers, and I suspect in VS by now, you can set the system to break on exception. In any case I imagine putting at least a throw; in there would be preferable for when you forget to remove the code, so the semantics don't change.

Volte
Oct 4, 2004

woosh woosh
Can't you just put the breakpoint on the closing brace?

RoadCrewWorker
Nov 19, 2007

camels aren't so great

zootm posted:

In most Java debuggers, and I suspect in VS by now, you can set the system to break on exception. In any case I imagine putting at least a throw; in there would be preferable for when you forget to remove the code, so the semantics don't change.
Thanks for pointing that out since im guilty of using senseless brakelines as well, ill have a look at that. Still, how would declaring a block variable that gets lost after the catch{} is done change the semantics of the program?

Victor
Jun 18, 2004
Unless a throw was omitted from the catch{} statement above, then adding the catch{} changes the semantics to the exception being handled. Not good!

zootm
Aug 8, 2006

We used to be better friends.

RoadCrewWorker posted:

Still, how would declaring a block variable that gets lost after the catch{} is done change the semantics of the program?
The exception isn't re-thrown; an exception that would otherwise propagate is silently ignored.

It really is best to avoid munging your program at all to make it "easier to debug"; this sort of thing can be too easy to leave in to a stage where it's more expensive to find and fix.

Volte posted:

Can't you just put the breakpoint on the closing brace?
In most languages you can't breakpoint on a line that isn't executed; braces are just syntax.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

ehnus posted:

In C# you can use System.Diagnostics.Debugger.Break(). C/C++ often have platform-specific ways of triggering a debug break point, and on PCs there's always interrupt 3. I'm not sure about other languages but they often have their own ways of breaking into the debugger
Having a do-nothing line is nice from a portability standpoint. Still, hasn't the stack already been unwound after the exception's been thrown, making it somewhat useless?

quote:

I suspect in VS by now, you can set the system to break on exception.
I'm still trying to find this.

OneEightHundred fucked around with this message at 23:15 on Jul 8, 2008

Volte
Oct 4, 2004

woosh woosh

zootm posted:

In most languages you can't breakpoint on a line that isn't executed; braces are just syntax.
Well it works in Eclipse with MinGW/GDB. :colbert:

zootm
Aug 8, 2006

We used to be better friends.

OneEightHundred posted:

I'm still trying to find this.
I've no idea, I'm afraid I don't use Windows so finding it is kinda impossible for me.

Edit: I lie, Google apparently knows about these things. See under Breaking on Exceptions on this page.

Volte posted:

Well it works in Eclipse with MinGW/GDB. :colbert:
That is some crazy-rear end poo poo. Good stuff though, would be nice if that worked more often.

zootm fucked around with this message at 23:21 on Jul 8, 2008

more falafel please
Feb 26, 2005

forums poster

zootm posted:

I've no idea, I'm afraid I don't use Windows so finding it is kinda impossible for me.

Edit: I lie, Google apparently knows about these things. See under Breaking on Exceptions on this page.

That is some crazy-rear end poo poo. Good stuff though, would be nice if that worked more often.

$10 completely fake dollars says it doesn't work with GCC and -O3.

As ehnus said, there's always int 3 (which can also be triggered with *(int*)13 = 3;

Coincidentally, *(int*)13 = 3 is a pretty good way of causing a breakpoint (not always a recoverable one) on any platform :)

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

more falafel please posted:

$10 completely fake dollars says it doesn't work with GCC and -O3.

What doesn't, breaking on exception? Works fine. Why is everyone so astounded by this?

Rottbott
Jul 27, 2006
DMC

zootm posted:

In most languages you can't breakpoint on a line that isn't executed; braces are just syntax.
You certainly can in Visual C and Visual C#, I do it every day.

CeciPipePasPipe
Aug 18, 2004
This pipe not pipe!!

more falafel please posted:

$10 completely fake dollars says it doesn't work with GCC and -O3.

As ehnus said, there's always int 3 (which can also be triggered with *(int*)13 = 3;

Coincidentally, *(int*)13 = 3 is a pretty good way of causing a breakpoint (not always a recoverable one) on any platform :)

Uh, wouldn't *(int*)13 = 3 cause a general protection fault (and possibly a bus error on archs that require aligned memory access), because you're trying to write the value 0x00000003 into memory at location 0x000000D ? I don't see how this has anything to do with interrupt 3.

TSDK
Nov 24, 2003

I got a wooden uploading this one

CeciPipePasPipe posted:

Uh, wouldn't *(int*)13 = 3 cause a general protection fault (and possibly a bus error on archs that require aligned memory access), because you're trying to write the value 0x00000003 into memory at location 0x000000D ? I don't see how this has anything to do with interrupt 3.
Interrupt 3 is a break to debugger. Causing a general protection fault will also stop execution and drop you to the debugger in most cases.

The only disadvantage is that you normally can't hit F5 and continue execution after hitting the latter, as you can with the former.

Personally, I use a 'DEBUG_BREAK()' macro which is defined on a per-platform basis.

Adbot
ADBOT LOVES YOU

CeciPipePasPipe
Aug 18, 2004
This pipe not pipe!!

TSDK posted:

Interrupt 3 is a break to debugger. Causing a general protection fault will also stop execution and drop you to the debugger in most cases.

The only disadvantage is that you normally can't hit F5 and continue execution after hitting the latter, as you can with the former.

Personally, I use a 'DEBUG_BREAK()' macro which is defined on a per-platform basis.

Oh ok, wouldn't it be easier to just do "int breakme=1/0;" or something then?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply