optional syntax
#1

was reading the pawn_lang.pdf, just curious as to why we strictly follow the C-like syntax in SA-MP scripting and not the one used in examples in the manual.

Код:
main()
    printf "Hello World!\n"
Код:
#include <a_samp>

main() {
    printf("Hello World!\n");
}
Reply
#2

Sorry buddy, explain a little bit further, so far I have "hello world" We need a_samp.inc in order for the console to run. Try running a gamemode without a_samp, if it works, I'll eat my words.
Reply
#3

Yes you can do it.
Reply
#4

for real? Hold up, let me check.

When including the Pawn includes, non-relative to SA:MP then it works.

But what's the point?

:CCC
Reply
#5

My answer was going to the author.
Reply
#6

Actually, you can call callbacks from Pawn, simply by forwarding the callback, not sure if it would run IG.
Reply
#7

Here's what I'm asking,

WHY can we do

Код:
#include <a_samp>

main() {
    printf("Hello World!\n");
}
and NOT

Код:
main()
    printf "Hello World!\n"
Notice no parenthesis or semi-colon in a function call in the second example?

Yet the manual says:

Quote:
Originally Posted by pawn_lang
neither style is “deprecated” or “considered harmful”
yet only the first exmple is valid in SA-MP scripting.
Reply
#8

Valid? Nothing like that.
pawn Код:
#include <sscanf2>
can be very well written in "SA-MP scripting" as
pawn Код:
#include "sscanf2"
Reply
#9

You can make the semicolon optional:
pawn Код:
#pragma semicolon 0
I'm not sure about the parenthesis. Why would you want to code in that style anyway? I find it very hard to read. I believe you also have to use parenthesis around multi-parameter functions anyway IIRC.
Reply
#10

Quote:
Originally Posted by Bakr
Why would you want to code in that style anyway? I find it very hard to read.
I don't. Apparently both are considered valid syntax (according to the manual) and should compile. Just curious as to whether it's some setting in the compiler when code is being parsed.

Quote:
Originally Posted by Vince
Braces are optional as well, but only if there is a just a single statement that follows.
Yes, either way. But what's interesting is the parenthesis ().
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)