| Jackson Marie (450) | |
| I really need opinions and suggestions or what you think about a project or something... And about myself, I don't need much code examples (Although I'm just a chicken in this large community...) This is prepairing... | |
|
Last edited on
|
|
| L B (3325) | |
| Prepairing, eh? I can see how it might be useful to pair things up earlier than usual. | |
|
Last edited on
|
|
| Jackson Marie (450) | ||||
|
I added comparsion symbols and bitwise operators... Now my idea :
Now I can write :
Next step : Multiple complex comparison expressions... | ||||
|
Last edited on
|
||||
| Jackson Marie (450) | |
|
Hey guys, I have a clear idea.... And, in short, this idea is : I will add a function which adds variables into a pointer vector list. Then while (in searching process), I only need to compare addresses between variable pointers and pointers. The method IMHO may give instant result. Perhaps. :) Generally speaking, the method above is fine, isn't it ? :-) | |
|
Last edited on
|
|
| L B (3325) | |
| Are you so prejudice against std::map that you will find the hardest possible alternative? | |
|
|
|
| Jackson Marie (450) | |||
|
Hi everyone! Today I've successfully added the"(a - b) ? x : y" construct into my expression calculating machine. Now we have more (a convenient way) to perform commands directly without using if - else conditions. The machine also has been redesigned completely (C++). I used map, vector instead of pointer. Also I fixed memory leak, bad variable memory allocation, and optimized the code a lot. The code now runs faster than the old one by 1.5x!!! Now I can write :
Next step : Parsing conditions... | |||
|
Last edited on
|
|||
| Jackson Marie (450) | |
| Hey guys : "150.000 characters per second..." - Fast, or slow? | |
|
|
|
| L B (3325) | |
|
In the US, that's very very slow. In non-crazy countries, that's still slow but not nearly as slow as in America. | |
|
|
|
| Jackson Marie (450) | |
| I did 1000 program loops, each loop has about 10000 characters. I used lots of parentheseses, and many comparsion expressions. To do this I used "strcat". "Parsing scripts" in my opinion it takes a lot of time, but the "calculating" process (I used another machine), I see it always finishs its work very quickly. | |
|
Last edited on
|
|
| Jackson Marie (450) | |
|
Seems I have to redesign the expression parsing machine... But, hey guys, I don't know using the global variables...is fast? or slow? Almost variables (except some important variables) I used "global". | |
|
|
|
| chrisname (5896) | |
|
Using global variables probably won't make any difference in performance, unless you try to parallelise your code (i.e., use threads). The more globals you have, the more thread synchronisation you have to do (which slows the program down), and the more likely deadlocks (which result in infinite loops) and data races (which can result in deadlocks or incorrect output) are to occur. More importantly, globals make your program more difficult to understand. Your brain can only keep track of so many variables at a time, but what it is good at is separating different contexts (the variables in a function are in a different context to the variables in a different function) because of the way human memory works (memory is aligned with locations, which is why people use the method of loci to memorise large volumes of data, and also why you might decide to do something in another room and forget what you're doing when you enter it, and then remember as soon as you leave). | |
|
|
|
| Volatile Pulse (1328) | |||
|
I hate to burst your bubble Jackson, but I believe what you're creating already exists on a much larger scale. See here for details: http://www.autohotkey.com/ Or the better one: http://l.autohotkey.net/ Code snippet:
It's built around, and possibly with, C++. It comes with it's own .exe builder, GUI based interface options when creating any kind of forms, and is designed with global mouse and keyboard hooks. I just wanted to show you some of the scripting languages that exist out there, not necessarily to discourage you, but to show you how much stuff exists out there, what their code looks like, the features they have, and the extensive knowledge the creators have. That's not to say that you have a bad idea by any means, I just don't know that you have enough knowledge for it yet, because I know I sure as well don't. Anyways, keep at it and if you need any help, post back here. | |||
|
|
|||
| Jackson Marie (450) | |
|
Very thanks guys. That encourages me a lot... By the way, I have a doubt : Does C++ support 'negating' command (Negatives the expression result and forces the result to take a boolean value). E.g : (>=) -> (<) (==) -> (!=) ....... Do you know? :) | |
|
Last edited on
|
|
| EssGeEich (681) | |
| Yes it does. But it's of no use, probably slower if unoptimized, and anyways the result of a common expression is already a boolean value. So you better stick with the builtins. | |
|
|
|
| Jackson Marie (450) | |||
Yes. Thanks @EssGeEich!! I added "negating" feature. The '!' sign symbol is used to negative the result of a expression and force the result to take a boolean value. Examples :x = !(5 > 2)In this case, the '!' symbol changes the greater (>) symbol to (<=) (Less or equal) x = !(!(10)) This expression is equal to x = (10 != 0)You can negative some of comparison symbols, E.g : x = (5 !!= 5) Similar expression : x = (5 == 5)x = (5 !> 5) Similar expression : x = (5 <= 5)Also I've just successfully added [type-casting] feature. IMO it is a way which converts a variable of one type, such as an int, a double,... to an another variable type, For E.g float->int... Currently I included unsigned, signed, char, bool, int. The default definition is float. And, if you choose unsigned without changing the variable type, the machine will automatically convert the value to unsigned (Keeps the decimal value). Otherwise, if the value needs to convert, the machine will convert to a proper value with its correspond type. Here's how : Let's take a look :
First of all the first case the tag [unsigned] converts the value "-57.35" -> "57.35" - Second : Same here, but it converts "-57.35" -> "57" - Third : The [int] tag converts the final result of the expression (3.64 - 2.46) to a regular integer value. - Fourth : Converts the final result of the expression (2.34 + 3) to a boolean value. - Fifth : The exact value is 16.6666666... But the [int] tag truncates the decimal result, generates "17", not "16" as the value of the default C++ type-casting. What do you think? Any suggestion or idea? Any mistake? :) | |||
|
Last edited on
|
|||
| Jackson Marie (450) | ||
|
Hi... Currently I got a trouble about C++ comparison expression. I tried to think up new idea but I couldn't. That is a very hard question. Because I have to calculate the expression, by hand :
The program always gives "0" but I have no idea what it did. How to calculate this expression type properly? Does anyone know? Help, please... | ||
|
Last edited on
|
||
| helios (10126) | |||
(0 && 3 && (5 < 2) || (100 > 10) || (4 / 2 > 3)) (0 || (100 > 10) || (4 / 2 > 3)) ((100 > 10) || (4 / 2 > 3)) (1 || (4 / 2 > 3)) (1) 1 If the operators have the wrong precedence, what will happen instead is ((4 > 5) && 3 && (5 < 2) || (100 > 10) || (4 / 2 > 3)) (0 && 3 && (5 < 2) || (100 > 10) || (4 / 2 > 3)) (0) 0 I question whether you should be programming at all if you don't understand how the language (by which I mean C++) evaluates its expressions. | |||
|
|
|||