In C, size_t is an unsigned type and its size is the size an int type takes on the underlying architecture. Because C is weakly typed you could however assign signed integers to a size_t type. The responsibility of using the types properly partly rests on the programmer. In your case since you are comparing the size_t type to zero it is fine. Try comparing it to a negative number. You would be surprised.
- Arvind
Django is both object oriented and MVC based framework written in Python. The Chapter 5: Models of the free Django book explains the MVC pattern as applied to Django. Also look at this SO question.
- Arvind
@noufalibrahim just sent you one. Though it will take some time before we can start waving.
laalto: Though hard to find the leave was caused by a failed memory allocation. The lesson I have learned is to TRAP every call that can leave. Thanks.
- Arvind
As mientefuego pointed out you grammar has the classic "dangling else" problem. You could beat the problem by assigning precedence to the rules that causes conflict. The rule causing conflict is: selection_stmt : IF '(' expression ')' statement | IF '(' expression ')' statement ELSE statement ; First start by making ELSE and LOWER_THAN_ELSE ( a pseudo-token ) non associative: %nonassoc LOWER_THAN_ELSE %nonassoc ELSE This gives ELSE more precedence over LOWER_THAN_ELSE simply because LOWER_THAN_ELSE is declared first. Then in the conflicting rule you have to assign a precedence to either the shift or reduce action: selection_stmt : IF '(' expression ')' statement %prec LOWER_THAN_ELSE ; | IF '(' expression ')' statement ELSE statement ; Here, higher precedence is given to shifting. I have incorporated the above mentioned corrections and listed the complete grammar below: /* C-Minus BNF Grammar */ %token ELSE %token IF %token INT %token RETURN %token VOID %token WHILE %token ID %token...
- Arvind
Download the source from the python website. Say you unzipped the source into a directory named Python-3.1.1. I suggest you two starting points within Python source code that would help you explore how Python works under the hood: Examine how the Python Virtual Machine executes the bytecode generated from the interperter. The Python VM is in the file named Python-3.1.1/Python/ceval.c. The core of the VM is an eval loop that starts at the function PyEval_EvalFrameEx in ceval.c. Read through the source and the inline comments. I am sure you would enjoy it. Another option is to look at how built-in python data types like lists, dictionaries and sets are implemented. For instance sets are implemented in Python-3.1.1/Objects/setobject.c. The Objects directory contains implementations of other data types as well. Hope this helps. Enjoy!!
- Arvind
I have a method pointer like below: typedef void (MMsnInternalCallBacks::* FuncPtr)(); FuncPtr iSoapActionComplete; I call the method below through the pointer iSoapActionComplete like below: (iCallbacks.*iSoapActionComplete)( ); While the function is being called a message "Memory Full. Try closing some applications" flashes on my Symbian S60 3rd Ed emulator. Any idea why this could be happening.
- Arvind
Are you sure that the functions increment and decrement execute without any error? I think it should raise an UnboundLocalError because you have to explicitly tell Python that you want to use the global variable named 'c'. So change increment ( also decrement ) to the following: def increment(): global c c += 1 I think as is your code is thread unsafe. This article about thread synchronisation mechanisms in Python may be helpful.
- Arvind
I guess you have got the wrong understanding about operator overloading. The idea of operator overloading is to present user-defined types with operations similar to those that could be performed on primitive types ( like integers ). Of course you could use operator overloading to overload the increment operator ( ++ ) that would actually decrement some member variable's value but you would surprise the users of your class just the way you would if you reported the objects being compared as unequal even though you have found them to be equal under certain conditions. Doing such things may be fine for learning the concepts but don't take them anywhere beyond.
- Arvind
By what I get from your question its a good case for interprocess communication. You say that you need to be notified when a file in a directory is created. Now, doing interprocess communication through files is bad in my opinion. In Unix you have several alternatives for interprocess communication as this guide details. Using Unix sockets would be the simplest way to go. If you have written the other process that now creates a file for interprocess communication you could change the implementation to write it to the socket.
- Arvind