Raised This Month: $32 Target: $400
 8% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-05-2016 , 12:33   Re: New API and Syntax
Reply With Quote #771

Once again, you massively over-estimate the cost of the behaviour that you are complaining about.
__________________
asherkin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 09-05-2016 , 19:18   Re: New API and Syntax
Reply With Quote #772

Ehhhem... inline functions?
__________________
Neuro Toxin is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 09-06-2016 , 12:20   Re: New API and Syntax
Reply With Quote #773

Quote:
Originally Posted by Potato Uno View Post
Can we get inline stock support one of these days? Declare a stock function as inline and then have the compiler paste its contents right into the body of the code. I am usually hesitant to use stocks unless it really gives a code readability boost because having stocks willy nilly everywhere will amount to considerable stack creation overhead. The JIT C++ file uses inline functions almost everywhere, for example.

A prototype like:

PHP Code:
stock inline int MyFunction(int params
Or make it its own thing (separate from stock functions) like:

PHP Code:
inline int MyFunction(int params
Spoiler
SourcePawn preprocessor can replace stock inline function via macros.
PHP Code:
#define GetEntityName(%1,%2,%3) GetEntPropString(%1, Prop_Data, "m_iName", %2, %3) 
P.S. What exactly you want to do?

Last edited by Kailo; 09-06-2016 at 12:21.
Kailo is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 09-06-2016 , 17:48   Re: New API and Syntax
Reply With Quote #774

Quote:
Originally Posted by Kailo View Post
SourcePawn preprocessor can replace stock inline function via macros.
PHP Code:
#define GetEntityName(%1,%2,%3) GetEntPropString(%1, Prop_Data, "m_iName", %2, %3) 
P.S. What exactly you want to do?
don't forget multiline macros

PHP Code:
#define LoopDeadPlayers(%1)             for(int %1=1;%1<=MaxClients;++%1)\
                                                                                                          
if(IsClientInGame(%1) && !IsPlayerAlive(%1)) 
__________________

Last edited by nergal; 09-06-2016 at 17:48.
nergal is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 09-06-2016 , 18:39   Re: New API and Syntax
Reply With Quote #775

Quote:
Originally Posted by Kailo View Post
P.S. What exactly you want to do?
Looks like he want to save some functions calls.
Quote:
Originally Posted by Potato Uno View Post
I am usually hesitant to use stocks unless it really gives a code readability boost because having stocks willy nilly everywhere will amount to considerable stack creation overhead. The JIT C++ file uses inline functions almost everywhere
Use macros if you do not want function call, like when your call them too often.
The trade here is they are typeless, but saves you the call increasing the code size.


What kind program are you developing on SourcePawn to need so much performance to optimize your function calls stack? Some heavy mathematical computations?
I do not think bit brushing is the SourceMod aim, it is a virtual language. If you want so much performance write modules for Metamod:Source on C++, instead of write plugins for SourceMod which runs over Metamod:Source. Now you may use inline as you like.

Or even better, for extreme performance, everybody should stop writing programs for any OS, and do they to run straight on the x86_64 hardware. It would just difficult the multitasking.
Actually almost anyone does that, unless there is not OS. A very minimal OS should be usually used to easy things up, as deal with the hardware.

Thinking like that, may be could be good we have inline functions but, we would just be mimicking the C++ language where SourceMod is written. Then if so much things from C++ are necessary, why just do not write everything for Metamod:Source?
It should be because is harder as the SourceMod provides some hand library. As it goes, we may say inline functions may be implemented, but the big questions is...

Who is willing to do that? Do you have free time for it and support it? Is it really necessary?
I do not think it is really necessary. You may think why does C++ have that, and it is simple, C++ is very low language, used to create high performance applications (as our lovely games) to extract everything the hardware has to offer.
Then as SourcePawn is not for high performance applications, is not really necessary to have inline functions. Unless someone here have very free time and is willing to implement it.

Disclaimer: May be I am very wrong/crazy or may be not.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 09-06-2016 at 19:32. Reason: misspelling
addons_zz is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 09-06-2016 , 19:14   Re: New API and Syntax
Reply With Quote #776

Quote:
Originally Posted by addons_zz View Post
Looks like he want to save some functions calls.

Use macros if you do not want function call, like when your call them too often.
The trade here is they are typeless, but saves you the call increasing the code size.

What kind program are you developing on SourcePawn to need so much performance to optimize your function calls stack? Some heavy mathematical computations?
I do not think bit brushing is the SourceMod aim, it is a virtual language. If you want so much performance write modules for Metamod:Source on C++, instead of write plugins for SourceMod which runs over Metamod:Source. Now you may use inline as you like.

Or even better, for extreme performance, everybody should stop writing programs for any OS, and do they to run straight on the x86_64 hardware. It would just difficult the multitasking.
Actually almost anyone does that, unless there is not OS. A very minimal OS should be usually used to easy things up, as deal with the hardware.

Thinking like that, may be could be good we have inline functions but, we would just be mimicking the C++ language where SourceMod is written. Then if so much things from C++ are necessary, why just do not write everything for Metamod:Source?
It should be because is harder as the SourceMod provides some hand library. As it goes, we may say inline functions may be implemented, but the big questions is...

Who is willing to do that? Do you have free time for it and support it? Is it really necessary?
I do not think it is really necessary. You may think why does C++ have that, and it is simple, C++ is very low language, used to create high performance applications (as our lovely games) to extract everything the hardware has to offer.
Then as SourcePawn is not for high performance applications, is not really necessary to have inline functions. Unless someone here have very free time and is willing to implement it.

Disclaimer: May be I am very wrong/crazy or may be not.
Now C++ is a low level language? What's C to you then? lol C++ has inline functions as a way for programmers to hand-optimize code but that's no longer necessary because modern compilers are smart enough to self-inline functions that can be inlined.
__________________
nergal is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 09-06-2016 , 19:21   Re: New API and Syntax
Reply With Quote #777

Quote:
Originally Posted by nergal View Post
Now C++ is a low level language? What's C to you then?
What C has and C++ does not have?
If C++ have everything that C has, it is also a low level language.
If not, then thanks I was wrong, but if I recall correctly C++ is a C language extension.

I also should fix, saying very low level to low level, because very low level should be more like assembly and the binary code it self should be out of question or may be just add a very becoming very very low level language.

Quote:
Originally Posted by nergal View Post
C++ has inline functions as a way for programmers to hand-optimize code but that's no longer necessary because modern compilers are smart enough to self-inline functions that can be inlined.
Good point, instead of adding inline declarations to source pawn, is would be more interesting to make it smarter.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 09-06-2016 at 20:34. Reason: update
addons_zz is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 09-06-2016 , 19:27   Re: New API and Syntax
Reply With Quote #778

Quote:
Originally Posted by BAILOPAN View Post
FYI: Macro-functions are slated for removal.
__________________
ddhoward is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 09-06-2016 , 20:19   Re: New API and Syntax
Reply With Quote #779

Quote:
Originally Posted by nergal View Post
C++ has inline functions as a way for programmers to hand-optimize code but that's no longer necessary because modern compilers are smart enough to self-inline functions that can be inlined.
It's not only not necessary, the meaning of inline has basically changed. The compiler was always free to not inline something the programmer marked as inline and free to inline something the programmer didn't mark. I would expect any modern compiler to totally ignore it as a hint as to whether or not a function should actually be inlined.

In modern use, the keyword's secondary effect is the only thing that matters: it allows multiple definitions. In C++17, this is even more clear with inline variables as a feature.
Fyren is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 09-06-2016 , 23:30   Re: New API and Syntax
Reply With Quote #780

Quote:
Originally Posted by addons_zz View Post
What C has and C++ does not have?
If C++ have everything that C has, it is also a low level language.
If not, then thanks I was wrong.

I also should fix, saying very low level to low level, because very low level should be more like assembly and the binary code it self should be out of question or may be just add a very becoming very very low level language.


Good point, instead of adding inline declarations to source pawn, is would be more interesting to make it smarter.
Personally I put C as "mid level" while I'd put C++ as mid to high level.

as far as I know, C's only low level features are the direct use of references (pointers), unions, the ability to inline assembly, and direct system calls as functions such as malloc.
__________________
nergal is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode