Difference in returns
#1

Which the difference between


pawn Код:
forward Test(playerid);
public Test(playerid)
{
    SendClientMessage(playerid, ~1, "test");
    return 1;
}
and

pawn Код:
forward Test(playerid);
public Test(playerid)
{
    SendClientMessage(playerid, ~1, "test");
}
?


The same case in plain functions:


pawn Код:
Test(playerid)
{
    SendClientMessage(playerid, ~1, "test");
    return 1;
}
and

pawn Код:
Test(playerid)
{
    SendClientMessage(playerid, ~1, "test");
}

Which is the difference?

I already know that if I need a value I can return it with return but in void functions, in pawn doesn't exist void so, in void functions that executes 1 time and don't need to return any value.

like

Case with callback:

pawn Код:
public OnPlayerConnect(playerid)
{
    SetTimerEx("Test", 1000, false, "d", playerid);
    return 1;
}

Case with plain function:

pawn Код:
public OnPlayerConnect(playerid)
{
    Test(playerid);
    return 1;
}

I need to return a value in the Test function in both cases?


Thanks and respond only people that have understanded my doubt and have experience with this cases to avoid confusions.


Thanks again.
Reply
#2

pawn is typeless, therefore it doesn't support valueless type void (which you stated but keeps mentioning for some reason..)

return does as says, it returns a value. It's also very handy when passing control back to a block of code.
Reply
#3

Yes but you don't said me the difference between return a value or not. Thanks for the fast answer.
Reply
#4

Oh thanks ****** but the function will be slower if I put a return value at the end of it or it's the same thing?

the "void:" tag is in the YSI library?


Thanks.
Reply
#5

Oh, thanks a lot, I use too much your YSI libraries, they are great, it help me a lot and you too. Thanks for solving another of my doubts ******. I appreciate it a lot.
Reply
#6

Quote:
Originally Posted by JavoDiaz
Посмотреть сообщение
Oh thanks ****** but the function will be slower if I put a return value at the end of it or it's the same .
all it is, is an extra instruction but this is the LEAST of the your worries. So I'll answer as any sane person would...no.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)