|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On March 21 2011 22:12 shinarit wrote: My question is, why this expression is not independent from implementation?
int x = 10; x = x++;
This will either give you 10 or 11. Which i dont get why, it should be 10 clearly every time, as = has lower precedence than ++ (any form of it). So you increase x, than assign the old value to it, no way it can be 11. And yet, on some compilers it will be 11. Whats the reason behind this? Btw i tried it with C++ compilers.
explained here:
http://c-faq.com/expr/evalorder2.html
|
On March 21 2011 22:12 shinarit wrote: My question is, why this expression is not independent from implementation?
int x = 10; x = x++;
This will either give you 10 or 11. Which i dont get why, it should be 10 clearly every time, as = has lower precedence than ++ (any form of it). So you increase x, than assign the old value to it, no way it can be 11. And yet, on some compilers it will be 11. Whats the reason behind this? Btw i tried it with C++ compilers.
It is implementation dependant because the order of execution is undefined until it hits a sequence point (semicolon). This means it's free to the implementation to first increment, then assign the copied value or assign the original value, then increment.
Generally speaking, a value should only be modified once between any sequence points.
Didn't read it, but i think it should cover the concept: http://en.wikipedia.org/wiki/Sequence_point
|
On March 21 2011 21:42 Manit0u wrote: Hey guys, I'm in need for some training to become at least amateurish in Java for the purposes of web development and Python in general (to create/run scripts for statistical analysis).
Could you point me to some good online resources?
Java for the purpose of web development?
I think you need to be a lot more specific in what you're asking. More than likely Java is not what you need to be using.
|
On March 21 2011 22:16 Clearout wrote:Show nested quote +On March 21 2011 22:12 shinarit wrote: My question is, why this expression is not independent from implementation?
int x = 10; x = x++;
This will either give you 10 or 11. Which i dont get why, it should be 10 clearly every time, as = has lower precedence than ++ (any form of it). So you increase x, than assign the old value to it, no way it can be 11. And yet, on some compilers it will be 11. Whats the reason behind this? Btw i tried it with C++ compilers. In the way you put it in the example you are adding 1 after you set x = 10, so then it should always be 11. Or am I missing something?
Yes. Which C++ compilers gave 11 instead of 10? The standard justifies all the reasons you specified:
Clause 5.2.6.1 - Increment and decrement The value computation of the ++ expression is sequenced before the modification of the operand object.
Clause 5.17.1 - Assignment and compound assignment operators The assignment operator (=) and the compound assignment operators all group right-to-left. ...In all cases, the assignment is sequenced after the value computation of the right and left operands, and before the value computation of the assignment expression.
The precedence argument is also correct although there is not a specific clause to point to as to why it is true as precedence in the standard is specified by the context-free grammar for the language.
EDIT: I'm wrong, see below!
|
Hyrule18968 Posts
On March 21 2011 22:43 Fateless wrote:Show nested quote +On March 21 2011 21:42 Manit0u wrote: Hey guys, I'm in need for some training to become at least amateurish in Java for the purposes of web development and Python in general (to create/run scripts for statistical analysis).
Could you point me to some good online resources? Java for the purpose of web development? I think you need to be a lot more specific in what you're asking. More than likely Java is not what you need to be using. I'm gonna side with Fateless here. Java is not really a web language. You can make applets with it, but it's not really suited to web use. PHP, Perl, and (blegh) ASP are much better choices if you want to do web development.
|
On March 21 2011 22:48 tofucake wrote:Show nested quote +On March 21 2011 22:43 Fateless wrote:On March 21 2011 21:42 Manit0u wrote: Hey guys, I'm in need for some training to become at least amateurish in Java for the purposes of web development and Python in general (to create/run scripts for statistical analysis).
Could you point me to some good online resources? Java for the purpose of web development? I think you need to be a lot more specific in what you're asking. More than likely Java is not what you need to be using. I'm gonna side with Fateless here. Java is not really a web language. You can make applets with it, but it's not really suited to web use. PHP, Perl, and (blegh) ASP are much better choices if you want to do web development.
Or you can use Python in the Django framework. That is growing rapidly in popularity and is fairly easy to use, plus you have the full Python scripting language at your disposal.
|
On March 21 2011 22:28 Morfildur wrote:Show nested quote +On March 21 2011 22:12 shinarit wrote: My question is, why this expression is not independent from implementation?
int x = 10; x = x++;
This will either give you 10 or 11. Which i dont get why, it should be 10 clearly every time, as = has lower precedence than ++ (any form of it). So you increase x, than assign the old value to it, no way it can be 11. And yet, on some compilers it will be 11. Whats the reason behind this? Btw i tried it with C++ compilers. It is implementation dependant because the order of execution is undefined until it hits a sequence point (semicolon). This means it's free to the implementation to first increment, then assign the copied value or assign the original value, then increment. Generally speaking, a value should only be modified once between any sequence points. Didn't read it, but i think it should cover the concept: http://en.wikipedia.org/wiki/Sequence_point
Ah nevermind, you and antilegend are correct. I misinterpreted the standard (as you would imagine is easy to do >_<). The two clauses I quoted above would allow for the following sequences of operations of "x = x++":
1) 10 is returned from x++ (A) 2) 10 is assigned to x (B) 3) x is incremented (C)
-and-
1) 10 is returned from x++ (A) 2) x is incremented (C) 3) 10 is assigned to x (B)
In particular, they require that (A) must occur before (B) and that (A) must occur before (C) but the ordering between (B) and (C) is undefined.
|
EDIT: double post, please delete. =(
|
On March 21 2011 22:56 rackdude wrote:Show nested quote +On March 21 2011 22:48 tofucake wrote:On March 21 2011 22:43 Fateless wrote:On March 21 2011 21:42 Manit0u wrote: Hey guys, I'm in need for some training to become at least amateurish in Java for the purposes of web development and Python in general (to create/run scripts for statistical analysis).
Could you point me to some good online resources? Java for the purpose of web development? I think you need to be a lot more specific in what you're asking. More than likely Java is not what you need to be using. I'm gonna side with Fateless here. Java is not really a web language. You can make applets with it, but it's not really suited to web use. PHP, Perl, and (blegh) ASP are much better choices if you want to do web development. Or you can use Python in the Django framework. That is growing rapidly in popularity and is fairly easy to use, plus you have the full Python scripting language at your disposal.
Thanks, I'll take a look into this Django stuff. And for Java, I just wanted to know how much of actual Java/JS I'd need to know to do basic things using stuff like Google Web Toolkit (if at all) etc. But I think I've already found a good place to learn, with courses and tests at Java Blackbelt (and I think this link should be included in the OP).
|
On March 21 2011 22:23 Morfildur wrote:Show nested quote +On March 21 2011 22:07 Clearout wrote:Even my professor couldn't see why it wont work.  It doesn't reach the breakpoint in the keyPressed() method, nor will it it do a println() if I put it in there. So the keyPressed() method doesnt react at all. Morfildur: As it is now it is supposed to be added to the panel since I have nothing infront of the addKeyListener() method called in the constructor, even if I put this.addKeyListener() to make it explicitly add to the panel it doesn't make a difference when running it. I have also tested and made sure that the panel is focusable so I'm sure it has the keyboard focus. These things make me fairly sure that the problem has to lie somewhere else. But if you have any way of checking what you're saying please tell  Thanks for responding, TL is my last hope  Try stackoverflow.com for "last hope". I don't remember the GUI stuff for java, it's been a few years, but wasn't there a JForm or JFrame or something to which you add the panel? Try to add the handler to any other control you use, the form, the panel, images, buttons, anything. Then check where the keypress gets invoked. After googling a bit: try this.requestFocus() in the constructor after the setFocussable(true) Still not working Went to stackoverflow.com too and tried a lot of things suggested there regarding the focus, which seems to be the problem, yet nothing helped. Thanks for the effort and introducing me to that site! 
Edit: tiny breakthrough! The traces I added react when I add the keyListener to the frame, so it seems the frame may be the culprit!
Edit: after the breakthrough one of the folks at the stackoverflow forum figured it out, it's working now! SO HAPPY I'M JUMPING IN MY CHAIR
|
Hey folks! I'm an Electronical Engineering undergrad. We have to develop a game in C++ as our Programming project. Our teacher suggested using Dev C++ as the compiler and Allegro as the graphical ibrary. I'm wondering if there are any better library that I can use in Visual Studio (would love something easy to use and that doesn't conflict with Threads like Allegro does). Thanks in advance!
|
United Arab Emirates333 Posts
Heres a not so strict programming question but since im an IT Major i think it falls in the same category somewhat. Maybe not? Lets see.
I took a long course that was all about ERP and SAP systems. We discussed its benefits, why and how they're good. We even studied some case studies. Now what does SAP experience mean. When people ask for SAP experience, what do they expect, someone who has an idea of that is or someone who has definitely worked with them and knows exactly what is going on. Anyone got a clue? Why im asking here is cause some firms are asking for SAP programming. So maybe someone with that knowledge can shed some light.
|
On March 22 2011 00:32 Hoon wrote: Hey folks! I'm an Electronical Engineering undergrad. We have to develop a game in C++ as our Programming project. Our teacher suggested using Dev C++ as the compiler and Allegro as the graphical ibrary. I'm wondering if there are any better library that I can use in Visual Studio (would love something easy to use and that doesn't conflict with Threads like Allegro does). Thanks in advance!
I'm a big fan of SFML. Does pretty much everything you need in a very straight forward way (no setting up of 13 contexts just to load a picture etc.).
|
Hyrule18968 Posts
On March 22 2011 00:11 Manit0u wrote:Show nested quote +On March 21 2011 22:56 rackdude wrote:On March 21 2011 22:48 tofucake wrote:On March 21 2011 22:43 Fateless wrote:On March 21 2011 21:42 Manit0u wrote: Hey guys, I'm in need for some training to become at least amateurish in Java for the purposes of web development and Python in general (to create/run scripts for statistical analysis).
Could you point me to some good online resources? Java for the purpose of web development? I think you need to be a lot more specific in what you're asking. More than likely Java is not what you need to be using. I'm gonna side with Fateless here. Java is not really a web language. You can make applets with it, but it's not really suited to web use. PHP, Perl, and (blegh) ASP are much better choices if you want to do web development. Or you can use Python in the Django framework. That is growing rapidly in popularity and is fairly easy to use, plus you have the full Python scripting language at your disposal. Thanks, I'll take a look into this Django stuff. And for Java, I just wanted to know how much of actual Java/JS I'd need to know to do basic things using stuff like Google Web Toolkit (if at all) etc. But I think I've already found a good place to learn, with courses and tests at Java Blackbelt (and I think this link should be included in the OP). Now you've gone and mixed up JS and Java. While JS has Java in the name, it's not Java. JS is used for some of the flashier stuff, but if all you want is to do basic web design and statistical analysis, you do not want to use JS. PHP, Python, or Perl would be the best for that sort of thing. I prefer PHP myself.
On March 22 2011 00:32 Hoon wrote: Hey folks! I'm an Electronical Engineering undergrad. We have to develop a game in C++ as our Programming project. Our teacher suggested using Dev C++ as the compiler and Allegro as the graphical ibrary. I'm wondering if there are any better library that I can use in Visual Studio (would love something easy to use and that doesn't conflict with Threads like Allegro does). Thanks in advance! Dev-C++ is awful. Windows graphical programming is a bitch and a half in C++. If you're using Visual Studio then you are using the Microsoft compiler and not Dev-C++ anyway, which is a step in the right direction. I haven't used Allegro so I can't comment on it. MFC is the standard for Windows, but it's awful.
|
On March 21 2011 22:26 AntiLegend wrote:Show nested quote +On March 21 2011 22:12 shinarit wrote: My question is, why this expression is not independent from implementation?
int x = 10; x = x++;
This will either give you 10 or 11. Which i dont get why, it should be 10 clearly every time, as = has lower precedence than ++ (any form of it). So you increase x, than assign the old value to it, no way it can be 11. And yet, on some compilers it will be 11. Whats the reason behind this? Btw i tried it with C++ compilers. explained here: http://c-faq.com/expr/evalorder2.html
Thanks for the link, the first really good description of the stuff i read. Its just misleading if you try to imagine postincrement on int as a function (there you cant actually increment AFTER yielding the old value), as you would do with overloaded versions in classes. Thanks again, now it clear
|
On March 22 2011 00:32 Hoon wrote: Hey folks! I'm an Electronical Engineering undergrad. We have to develop a game in C++ as our Programming project. Our teacher suggested using Dev C++ as the compiler and Allegro as the graphical ibrary. I'm wondering if there are any better library that I can use in Visual Studio (would love something easy to use and that doesn't conflict with Threads like Allegro does). Thanks in advance!
Trick everyone and create a MUD. Or just take a MUD code and add graphical interface to it (there are quite a lot of mudlibs available for free download). I mean, you only need to focus on your gamedriver then, since all the libraries, which include access protection, parsing, admin/user commands and actions, in-game communication, moving about files and objects, compiling and testing are all there. And on top of that, you get your share of standard objects and basic combat/trading systems and what not. That's quite a bundle to have for starters and expand on.
That is, of course, if you'd like to create a sort of an RPG.
Here are some samples for the bold: http://lpmuds.net/downloads.html
|
On March 22 2011 00:32 Hoon wrote: Hey folks! I'm an Electronical Engineering undergrad. We have to develop a game in C++ as our Programming project. Our teacher suggested using Dev C++ as the compiler and Allegro as the graphical ibrary. I'm wondering if there are any better library that I can use in Visual Studio (would love something easy to use and that doesn't conflict with Threads like Allegro does). Thanks in advance!
i can't really make a comparison to other libraries, but in university we programmed a game in C++ with SDL http://www.libsdl.org , and as far as i can remember it was quite good and easy to use.
|
On March 22 2011 00:48 tofucake wrote: Dev-C++ is awful. Windows graphical programming is a bitch and a half in C++. If you're using Visual Studio then you are using the Microsoft compiler and not Dev-C++ anyway, which is a step in the right direction. I haven't used Allegro so I can't comment on it. MFC is the standard for Windows, but it's awful.
I've primarily used Dev C++ through college since its what the professor recommended and was installed on the lab computers. I'm curious what makes it awful? I never had any gripes with it and it was simple to use. Though I must say I haven't done any projects on a large scale with C++ yet.
|
Hasn't Dev-C++ been obsolete since like 2005 (at least that's the last time it has been supported/released) and replaced with wxDev-C++ later on?
|
On March 22 2011 03:43 AntiLegend wrote:Show nested quote +On March 22 2011 00:32 Hoon wrote: Hey folks! I'm an Electronical Engineering undergrad. We have to develop a game in C++ as our Programming project. Our teacher suggested using Dev C++ as the compiler and Allegro as the graphical ibrary. I'm wondering if there are any better library that I can use in Visual Studio (would love something easy to use and that doesn't conflict with Threads like Allegro does). Thanks in advance! i can't really make a comparison to other libraries, but in university we programmed a game in C++ with SDL http://www.libsdl.org , and as far as i can remember it was quite good and easy to use.
I agree on this. Lazyfoo is providing some excellent tutorials on how to get started with SDL.
|
|
|
|