New child language - (Function member address (structure))

Pages: 1... 151617181920
What's this? People are actually reading this thread?

</wiseguy>
Last edited on
Hey guys, in my opinion "formatting variable structure" is a good idea. And you? :)

 
world->variable_list[variable_length][variable_name];


:D
Last edited on
We have |olutely| no idea what that means.
L B Imagine it looks like variable sorting - filtering (better than switch-case).
1
2
3
4
5
char *var_name = "abc";
int length = 3;

if(world->Search(length, var_name)) //Suppose it's true
world->variable_list[length][var_name]...

Continue? :)

Second, generally I was shocked, because two trivial expressions I measured are wildly different... :C

Take a look at two examples :
1
2
3
4.00 ^ 2.00 ^ 2.00; // Direct

pow(pow(4.00, 2.00), 2.00); //Indirect 

As you can see, both two solutions are certainly correct... But unfortunately, the code speed & performance, it's so terrible! And here's actually my function speed :
- Operators per second :
Power operator : 1.500.000 operators per second
(It took about 14 seconds to complete...)
Function : Below 200.000... D:
(It took about 69 seconds to complete...)

And about you, do you agree? How to fix and improve the function speed efficiently?
Last edited on
You can improve performance by not running your tests on one of the original vacuum tube computers. Have you considered upgrading to DOS?
Structure : Prepairing....
NB : Redundant post

1
2
3
4
5
6
7
struct POINT
     {
     int x;
     int y;
     };

BOOL GetCursorPos(POINT &pt);


1
2
3
4
5
6
7
8
9
char *buffer = new char[8];
void * void_pointer = buffer;
POINT *pt = (POINT*)void_pointer;
///////////////////////////////////
GetCursorPos(pt);
///////////////////////////////////
int *point = (int*)void_pointer;
printf("The X point : %d\n", point[0]); // POINT::x
printf("The Y point : %d\n", point[1]); // POINT::y 


Interpreter (short, instantly) :
1
2
3
4
5
6
7
8
9
char buffer[8];

///////////////////////////////////
GetCursorPos(buffer);
///////////////////////////////////

int *point = buffer;
printf("The X point : %d\n", point[0]); // POINT::x
printf("The Y point : %d\n", point[1]); // POINT::y 


EDIT : New multiple dimensional array concept has been found!!!
1
2
3
4
5
6
7
8
9
char string_temp[100][10];
strcpy(string_temp[0], "112233445566"); //12-characters

std::cout << "String : ";
std::cout << std[0] << std::endl; //That.
std::cout << std[1] << std::endl;

std::cout << "string_temp[10] = ";
std::cout << std[0][10] << std::endl; //Doesn't crash!!!!!!!!!!! 



Function : Over 100 functions have been added!!!!!!!!!!!

:O
Last edited on
L B wrote:
You can improve performance by not running your tests on one of the original vacuum tube computers. Have you considered upgrading to DOS?


What do you mean by that? ~~ - What does that mean?

EDIT : Hey guys, I don't really understand cin, cout... Is it a structure? Or something else?
Last edited on
std::cout, std::wcout, std::cerr, std::wcerr, std::clog, std::wclog, std::cin, and std::wcin are global objects that are istreams and ostreams.
http://en.cppreference.com/w/cpp/io
Scroll down to "Predefined standard stream objects:"

Jaskson Marie wrote:
What do you mean by that? ~~ - What does that mean?
It means you need to consider upgrading to an operating system such as DOS rather than just using vacuum tube computers. After DOS, you can move to Windows 3.1 when you feel comfortable. You'd still be about four to five versions behind the most recent technology, but it would be a step in the right direction.
Last edited on
@Jackson Marie, what is your native language? Clearly, you're not friends with English. Maybe we could use that information to somehow to improve our communication...
Jackson Marie wrote:
Function : Over 100 functions have been added!!!!!!!!!!!

Are you even manually adding them? Isn't that a bit dumbish idea? What if an user wants to provide his own functions, say from a DLL?
Agree with hamsterman (@Jackson Marie, what is your native language? Clearly, you're not friends with English. Maybe we could use that information to somehow to improve our communication... )

Yes. Weird. But secretly I won't say anything until the end of this project. :)
Edit :

EssGeEich
: How to import and get function address of a Dll function?
Last edited on
Thanks and with thousands of functions, I consider maybe I'll need to upgrade the function library to level 3 to improve speed function browsing and achieve "the fastest function indirect access". :)

Edit : Also I'm going to make some additional functions which control manage the function library on demand. In my point of view it's so interesting because if this feature is added, because users can freely import, view and add their own functions... :D
SECOND EDIT :
Function type-cast is about to be upgraded to level 2, when a function item can carry a large amount of information. But if you specify a function with special parameters (e.g pointer), probably basic function type-cast will not be able to help you.
Last edited on
I consider maybe I'll need to upgrade the function library to level 3


What does that mean?
What does that mean?


Oh not much, just about another 15 update posts about functions, and then we will hit level 4.

By the way Jackson Marie you never answered my question about the directX capabilities for you interpreter. You just seem to ignore questions that ask for specifics...
coder7777 wrote:

By the way Jackson Marie you never answered my question about the directX capabilities for you interpreter. You just seem to ignore questions that ask for specifics...


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
void CallMe(int phone_number);
bool DirectXInit();

int main()
{ 
     function_library_manager function_library;

     function_library.AddItem('C' , ONEPARAM, "CallMe" , CallMe, _DOESNOTRETURN, _CDECL);
     function_library.AddItem('D' , ZEROPARAM, "DirectXInit" , DirectXInit, _RETURNS, _CDECL, T_BOOL);
     return 0;
}

void CallMe(int phone_number)
{
     std::cout << "HELLO? This is " << phone_number << std::endl;
}

bool DirectXInit()
{
        LPDIRECT3D9 pD3D;
	D3DDISPLAYMODE Mode;

	pD3D=Direct3DCreate9(D3D_SDK_VERSION);
	if(pD3D==NULL)
	{
		ThrowError("Error : Cannot create D3D interface");
		return false;
	}

	if(FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &Mode)) || Mode.Format==D3DFMT_UNKNOWN) 
	{
		ThrowError("Cannot determine desktop video mode");
		return false;
	}
//Continue...
//////////////////////////////////////////////////////////////////////////////////////
}



coder7777 wrote:

Oh not much, just about another 15 update posts about functions, and then we will hit level 4.



???


Please, look again, the idea I mentioned on the top.
Switching from level 2 to level 3 is too easy, so my next 15 posts only just are :



1
2
3
function_list[first_character][last_character][Item_index];

function_list[first_character][last_character][number_of_parameters][Item_index];




This is called "ultra-fast search method"

You only specify several necessary parameters, and immediately it will give the instant result!!!
(Instead of scanning the library million times)

As you can see, the parameter "first_character", "last_character" are regular char values. So the size of those arrays must be sizeof(char) = [256].
Simply for example :

"My_function"
(First character is "M" and last character is "n")

Checking :



1
2
3
4
5
6
7
8
//Valid item : "My_function"
//Basic conditions : ['M']['n']

my_function : The first character is invalid, so the request is aborted
My_functioN : The last character is invalid
Myfunction : All its basic conditions are allowed, but "Myfunction" is not found 

My_function : Accepted!!!



So, is it much better than switch-case filter and linear-search with ultra-slow strcmp?? :)


Now the range is expanded, I want to add "number_of_parameters" suppose its size is 64 (may vary if needed).

So, accessing a function certainly is safer. Consider the example :

1
2
3
4
//Item strcmp (['s']['p'][2]) //Two parameters

strcmp(string_temp, "HA!"); //Valid
strcmp(string_temp, "HA!", 2); //Ignored - just because there isn't any "strcmp" function which has three parameters  



About range :


Function level 0 : 8000 kb
Function level 1 : 2000 kb + switch case
Function level 2 : 256 x 256 = 65536 (cases) + simple filter
Function level 3 : 256 x 256 x 64 = 4194304 (cases) + ultra lighting speed !!!!!!!!!!!!!!!!!!!!!!



How do you feel about this idea? Do you understand it? Any opinion or suggestion guys? :)
Last edited on
Oh, I defined <vararray> and... had no idea about the crazy compiling errors.

Still no idea "why", because I don't know what's wrong with the standard code :
1
2
3
4
5
6
7
8
9
10
11
12
	_Ty min() const
		{_Ty _Min = _Ptr[0];
		for (size_t _I = 0; ++_I < size(); )
			if (_Ptr[_I] < _Min)
				_Min = _Ptr[_I];
		return (_Min); }
	_Ty max() const
		{_Ty _Max = _Ptr[0];
		for (size_t _I = 0; ++_I < size(); )
			if (_Max < _Ptr[_I])
				_Max = _Ptr[_I];
		return (_Max); }


Then the compiler throws up to 100 errors... :(


valarray(104) : warning C4003: not enough actual parameters for macro 'min'
valarray(110) : warning C4003: not enough actual parameters for macro 'max'
valarray(104) : error C2059: syntax error : 'function-style cast'
valarray(167) : see reference to class template instantiation 'std::valarray<_Ty>' being compiled
valarray(104) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
valarray(167) : see reference to class template instantiation 'std::valarray<_Ty>' being compiled
valarray(109) : error C2143: syntax error : missing ')' before '}'
valarray(167) : see reference to class template instantiation 'std::valarray<_Ty>' being compiled
valarray(109) : error C2059: syntax error : ')'
       
.....????????????


Why this caused? And how to fix those compiling errors?
Many thanks. :)
Last edited on
...Although many of this are uncompleted, but I really want to hear some first suggestions and opinions about my interpreter.

Would you like to test my first program? (You'll need to read these information below carefully)

Some notes :
0. Function type-cast pow([#dd]true,2.0);

1. Code warning :
http://www.cplusplus.com/forum/lounge/85713/14/#msg483215

2. Structure-Handmade Function
"Structure-Handmade Function" - unsupported features. So please use void* definition (temporarily) instead and if necessary, pick a proper pointer to access structure data.
(See the example at the previous page.)

3. Conditional expression IF_WHILE-FOR : Sorry, In progress :)

4. Special Libraries (std::cin - std::cout...) - Currently completely unsupported.

5. Format signs (/**/) (//) - in progress

How to test : Create a text file,
write your own code,
run the program,
pick a source file,
enjoy your program!



//Example :
1
2
3
4
5
6
7
8
9
10
11
 char str[80];
  int i;

  printf("Enter your family name: ");
  scanf("%s",str);  
  printf("Enter your age: ");
  scanf("%d",&i);
  printf("Mr. %s , %d years old.\n",str,i);
  printf("Enter a hexadecimal number: ");
  scanf("%x",&i);
  printf("You have entered %#x (%d).\n",i,i);


Another examples :
1
2
3
4
 char buffer[50];
  int n, a=5, b=3;
  n = sprintf(buffer, "%d plus %d is %d", a, b, a+b);
  printf("[%s] is a string %d chars long\n",buffer,n);


1
2
3
4
5
6
7
8
9
10
11
12
13
14
  void * pFile;
   char name[100];
   char strfile[256];

     puts("Enter your output file : ");
     gets(strfile);

   pFile = fopen(strfile ,"w");

     puts("Please, enter a name : ");
     gets(name);
     fprintf(pFile, "The name you have entered : [%s]\n",name);
   
   fclose(pFile);



//See the main page for more details.

Do you want to test my program right now? If so, certainly I'll update & post my test program and any of your help would be greatly appreciated. If not, probably you'll need to wait at least one week, that's enough to complete "Conditional expression"... :)
Last edited on
Before including vararray you should #undefine min and max

Anyways I find it tedious to write a file to use an interpreter - sadly that's how most interpreters act like, but I prefer a realtime code interpreter.

Obviously in case of a while you should keep inputting lines, provided you are going to do it real-time.
Last edited on
Pages: 1... 151617181920