Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 201 202 [203] 204 205 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 886967 times)

Fenrir

  • Bay Watcher
  • The Monstrous Wolf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3030 on: September 30, 2012, 05:20:48 pm »

I used goto in C once.

Code: [Select]
void func() {
     int *foo1, *foo2;

     foo1 = (int*) malloc(10*sizeof(int));
     if (foo1 == NULL)
          goto exit1;

     foo2 = (int*) malloc(10*sizeof(int));
     if (foo2 == NULL)
          goto exit2;

     /* ... */

    exit2:
    free(foo1);

    exit1:
    fputs(stdin, "Failed to allocate memory");
}

It was something like that. I do not recall what project this was.
« Last Edit: September 30, 2012, 05:28:27 pm by Fenrir »
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3031 on: September 30, 2012, 05:33:40 pm »

I used goto in C once.

Code: [Select]
void func() {
     int *foo1, *foo2;

     foo1 = (int*) malloc(10*sizeof(int));
     if (foo1 == NULL)
          goto exit1;

     foo2 = (int*) malloc(10*sizeof(int));
     if (foo2 == NULL)
          goto exit2;

     /* ... */

    exit2:
    free(foo1);

    exit1:
    fputs(stdin, "Failed to allocate memory");
}

It was something like that. I do not recall what project this was.

Code: [Select]
void func() {
     int *foo1, *foo2;

     foo1 = (int*) malloc(10*sizeof(int));
     if (foo1 == NULL) {
          fputs(stdin, "Failed to allocate memory");
          return;
     }

     foo2 = (int*) malloc(10*sizeof(int));
     if (foo2 == NULL) {
          exit2:
          free(foo1);
          fputs(stdin, "Failed to allocate memory");
          return;
     }

     /* ... */

    free(foo1);
}

This version of that exact same code both avoids goto and doesn't print an error message when func() exits without a memory allocation error.

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3032 on: September 30, 2012, 05:35:11 pm »

I almost used goto in C++ once. Then I came to my senses.

In Lua, loops don't have a continue command. There's break, but no continue. You can fudge it using goto, though.
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3033 on: September 30, 2012, 08:21:08 pm »

alway, that's propaganda spread by Windows, DirectX likes to say, soo our new version (say DirectX11) has this crazy new feature! thats brand new and never been used before!
what they don't tell you, is that OpenGL has had it for months or even years now, no they're too busy showing you how great DirectX is.
this is what happened with tessellation as well as many other features.  Plus they use scare tactics to drive programmers away from OpenGL, by claiming windows isn't going to support OpenGL, ( a claim they've made with Windows XP, Vista, and 7) they say they aren't going to support it so programmers shouldn't use it if they want to make games on windows, then when the OS comes out, it turns out that it actually DOES support it, and they were just lying about not supporting it.
Source?
Logged

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3034 on: September 30, 2012, 09:24:54 pm »

I remember reading various articles saying similar things. It seems like something M$ would do.
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3035 on: September 30, 2012, 09:35:04 pm »

I remember reading various articles saying similar things. It seems like something M$ would do.
Yes, but 'it seems like something they would do' just makes it even more likely to be hearsay. :P

So again, without an actual source, it's just hearsay vs hearsay.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3036 on: October 01, 2012, 12:36:28 am »

I remember reading various articles saying similar things. It seems like something M$ would do.
Yes, but 'it seems like something they would do' just makes it even more likely to be hearsay. :P

So again, without an actual source, it's just hearsay vs hearsay.

I can hearsay better than you!

On topic, I managed to get the GUI component of my CompSci project working. I now have an 8x8 board of JButtons with icons to represent colored pieces, that do stuff when I click them. Now I just have to write the under-the-hood code for Reversi, and tie it to the GUI. Luckily, I'm more familiar with that part.

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3037 on: October 01, 2012, 02:12:40 am »

So again, without an actual source, it's just hearsay vs hearsay.
Not for me, as I've read various articles. I'd provide links, but it's been a while and I didn't save them.
Logged

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3038 on: October 01, 2012, 03:11:20 am »

Plus they use scare tactics to drive programmers away from OpenGL, by claiming windows isn't going to support OpenGL
Source?

this actually happened @Vista: they dropped xp opengl drivers, building that over directs; then they dropped opengl over directx driver support, because it was a mess, then provided a buggy and unusable software renderer; with the final idea that it was now over the video card driver to instal the appropriate opengl renderer

there was a brief period of instability, then since everyone had this or that card everyone ended up with a working opengl driver and nobody really noticed what happened except those running on pre rtm stuff.

http://slashdot.org/story/05/08/06/177251/windows-vista-may-degrade-opengl

if you run a very very old card with vga driver (so that no driver package gets installed on your vista) you'll find out that opengl stuff crashes or tells that 'there is no OpenGL installed'. but if you have that kind of card in the first place you're not going to make any use of opengl, so it was a catch.





Logged

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3039 on: October 01, 2012, 03:58:09 am »

I almost used goto in C++ once. Then I came to my senses.

There's one case I'd use goto in C++: as a substitute for "break(2);" (although you can fudge around it by putting the loops in a function and using return instead).

It's one of those statements that's rarely needed but used correctly can make code a lot cleaner.
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3040 on: October 01, 2012, 04:32:28 am »

I don't feel like looking for some source maybe tomorrow, right now I'm banging my head against the wall, I can't get SDL_TTF to work in this dumb thing, I've gotten it to work in other programs, but it just doesn't want to work, if I include TTF_Init();  it crashes o_O


nvm fixed it, forgot that zlib1.dll is needed for SDL_TTF
« Last Edit: October 01, 2012, 04:38:46 am by Valid_Dark »
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3041 on: October 04, 2012, 11:27:29 am »

http://rosalind.info/

Saw this on slashdot today.  Its a set of programming problems with a bioinformatics focus.  The neat bit is that they also treat it like an RPG.  As you solve problems you can gain experience and level up.  Kind of neat.   Depending on my free time I might have to play with it a bit. 
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3042 on: October 04, 2012, 03:25:54 pm »

Nice I need to take a bash at that one.
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

Knight of Fools

  • Bay Watcher
  • From Start to Beginning
    • View Profile
    • Knight of Fools
Re: if self.isCoder(): post() #Programming Thread
« Reply #3043 on: October 04, 2012, 06:09:15 pm »

I got my fist taste of exception handling in Java today and I enjoyed the crap out of it. I always get a kick out of exception handling.

I am not sure how I feel about my love of exception handling.
Logged
Proud Member of the Zombie Horse Executioner Squad. "This Horse ain't quite dead yet."

I don't have a British accent, but I still did a YouTube.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3044 on: October 04, 2012, 10:56:22 pm »

I got my fist taste of exception handling in Java today and I enjoyed the crap out of it. I always get a kick out of exception handling.

I am not sure how I feel about my love of exception handling.

That typo made me imagine you taking a bunch of Java exceptions in your hand, crushing them in your fist, and shoving the entire fist in your mouth.

As far as I can tell, Java exception handling is essentially identical to C++ exception handling. If I'm wrong, would someone mind pointing it out?
Pages: 1 ... 201 202 [203] 204 205 ... 796