Thread: Need a C++ guru
View Single Post
  #10  
Old 07-01-2009, 01:04 AM
Kobaz
Hill Giant
 
Join Date: Nov 2008
Location: Gold Coast, Oz
Posts: 119
Default

This thread is about to go way off topic....

I was thinking of modifying the game to make it far more friendly for my kids (the youngest is only 7), so I wanted to add easier corpse recovery, and commands that would be richer macros to make it more fun for them, whilst requiring them to think and read more. So I was digging around in the code, trying to make sense of it. I was getting confused by the compiler warnings.

The problem seems to be that I read an expression like "a > b" as "the message > is sent to the instance a with the argument instance b", but it seems that a doesn't know that it's being asked to compare itself to b, because it isn't! This seems to me to be a pure procedural language with classes, and not an OOL as I understand it, which is objects being sent messages, even classes are just objects (Smalltalk background - I haven't done procedural programming for many many years). int is not an object in C++, indeed it seems that only things that are explicitly called with new are objects, which is not what I'm used to!

In Smalltalk everything in the code is either a reference or a message to a reference to an instance. If an Integer is asked to compare itself to another class, it sends a message to that class to create a new instance of the other class from itself (the Integer), and passes the message and argument to the new reference, and returns the result (this is polymorphism). This is clearly not how C++ works. I'm not sure that I have the time to learn another language, especially one that has some features that look a bit OOL but work completely differently, given my very busy life. It's the subtleties that will stymie me, as I have worked with C a long time ago, but the emu code is sufficiently different (and far more sophisticated) than any C I ever wrote that I seem to spend more time trying to work out what the language is doing than actually implementing anything.
Reply With Quote