Raised This Month: $51 Target: $400
 12% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
nergal
Veteran Member
Join Date: Apr 2012
Old 09-18-2016 , 21:12   Re: New API and Syntax
Reply With Quote #791

if I may ask, what is the update to lambda funcs/closures?

I've actually encountered a situation where a lambda func would've been useful and save a good number of lines of code.
__________________
nergal is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 09-27-2016 , 23:02   Re: New API and Syntax
Reply With Quote #792

also on the topic of functions.

is it possible to return a fixed sized array from a function instead of an arbitrary one?

for example, the following function works but it won't let me return it as "float[3]"
PHP Code:
stock float[] nAddVectors(const float vec1[3], const float vec2[3])
{
    
float result[3];
    
result[0] = vec1[0] + vec2[0];
    
result[1] = vec1[1] + vec2[1];
    
result[2] = vec1[2] + vec2[2];
    return 
result;

__________________
nergal is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 09-28-2016 , 00:53   Re: New API and Syntax
Reply With Quote #793

Asherkin said on some thread (which conveniently I cannot find the link to) that returning arrays will never be fully supported.
Potato Uno is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 09-28-2016 , 10:13   Re: New API and Syntax
Reply With Quote #794

Quote:
Originally Posted by Potato Uno View Post
Asherkin said on some thread (which conveniently I cannot find the link to) that returning arrays will never be fully supported.
so it will be half supported? quarter-supported?

that makes no sense considering the point is to make sourcepawn more like C# and Java, both of which can return (arbitrary sized) arrays.
__________________
nergal is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 10-14-2016 , 22:49   Re: New API and Syntax
Reply With Quote #795

why does doing...

PHP Code:
"myString"[0]; 
...throw an error? Can I not instantly access a lazy string?
__________________
nergal is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 10-15-2016 , 09:29   Re: New API and Syntax
Reply With Quote #796

Why don't you do 'm' for once? Does C++ accept it?

Quote:
Originally Posted by nergal View Post
Can I not instantly access a lazy string?
Yes, that is what the compiler tells you, when it throws an error.
Or your question is, how to access a lazy string?
Anyways this sounds wrong to me and looks like something related to macro things.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective
addons_zz is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 10-15-2016 , 09:57   Re: New API and Syntax
Reply With Quote #797

Quote:
Originally Posted by nergal View Post
why does doing...

PHP Code:
"myString"[0]; 
...throw an error? Can I not instantly access a lazy string?
https://github.com/alliedmodders/sourcepawn/pull/58
__________________
WildCard65 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 10-19-2016 , 03:49   Re: New API and Syntax
Reply With Quote #798

Quote:
Originally Posted by BAILOPAN View Post
I myself look forward to a point in time when we have API calls like this:
PHP Code:
native string GetClientName(int client); 
I know we'd need true strings and figure alot of stuff out, but how far ahead until we start seeing stuff like this?

Last edited by headline; 10-19-2016 at 03:57.
headline is offline
exc4libur
Member
Join Date: Oct 2015
Old 11-03-2016 , 15:16   Re: New API and Syntax
Reply With Quote #799

Hello,

can someone help me how to write the following statement with new syntax? It is one of the cURL_self_test statements.

PHP Code:
stock bool ExecCURL(Handle curlint current_test)
{
        [
B]curl_easy_perform_thread(curlonCompletecurrent_test);[/B]
}

public 
void onComplete(Handle hndlCURLcode codeany data)
{
    if(
hndl != INVALID_HANDLE && code != CURLE_OK)
    {
        
char error_buffer[256];
        
curl_easy_strerror(codeerror_buffersizeof(error_buffer));
        
CloseHandle(hndl);
        return;
    }
    
    
TESTCASE_CLOSEHANDLE(hndl)
    
TESTCASE_CLOSEHANDLE(gs_access_file)


I always get the error
Code:
 error 100: Prototypes do not match -> curl_easy_perform_thread(curl, onComplete, current_test);
Code:
/**
 * Perform a file transfer, using thread
 * @ param Handle            hndl                The handle of the curl to be used. May be INVALID_HANDLE if not essential.
 * @ param CURL_OnComplete    perform_callback    The complete callback.
 * @ param cell_t            value                Value to set.
 * @ noreturn
 */
native curl_easy_perform_thread(Handle:hndl, CURL_OnComplete:perform_callback, any:value=0);

Last edited by asherkin; 11-03-2016 at 15:29. Reason: using code tags is hard
exc4libur is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 11-03-2016 , 15:31   Re: New API and Syntax
Reply With Quote #800

Quote:
Originally Posted by exc4libur View Post
can someone help me how to write the following statement with new syntax? It is one of the cURL_self_test statements.
Your onComplete function needs an int return, not void.
__________________
asherkin 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 11:47.


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