Pragmatic directives: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Minor tidy) |
(Added FreeBASIC) |
||
Line 305: | Line 305: | ||
Additionally, parsing words sometimes alter compiler behavior. For example, the compiler uses type information from <code>TYPED:</code> words for optimizations. |
Additionally, parsing words sometimes alter compiler behavior. For example, the compiler uses type information from <code>TYPED:</code> words for optimizations. |
||
=={{header|FreeBASIC}}== |
|||
FreeBASIC does not have pragmatic directives in the traditional sense. |
|||
However, it has several built-in keywords and functions that can affect program behavior in a similar way to pragmatic directives in other languages. |
|||
Thus, FreeBASIC has keywords such as <code>Public</code> and <code>Private</code> that can change the visibility of variables and functions within a module. |
|||
<syntaxhighlight lang="vbnet">Private Sub i_am_private |
|||
End Sub |
|||
Public Sub i_am_public |
|||
End Sub</syntaxhighlight> |
|||
It also has keywords like <code>CDecl</code>, <code>Pascal</code> and <code>StdCall</code> that can change the calling convention of a function. |
|||
Cdecl is usually the default calling convention for C compilers and is used almost exclusively on Unix, Linux, *BSD, and DOS-like systems. |
|||
<syntaxhighlight lang="vbnet">' declaring 'strcpy' from the standard C library |
|||
Declare Function strcpy Cdecl Alias "strcpy" (Byval dest As ZString Ptr, Byval src As ZString Ptr) As ZString Ptr</syntaxhighlight> |
|||
Pascal is the default calling convention for procedures in Microsoft QuickBASIC and is the standard convention used in the Windows 3.1 API. |
|||
<syntaxhighlight lang="vbnet">Declare Function MyFunctionPascal Pascal Alias "MyFunction" (param As Integer) As Integer</syntaxhighlight> |
|||
Stdcall is the default calling convention on Windows and the most common in BASIC languages and the Windows API. |
|||
<syntaxhighlight lang="vbnet">Declare Function MyFunc1 Stdcall (param1 As Integer, param2 As Integer) As Integer</syntaxhighlight> |
|||
=={{header|Go}}== |
=={{header|Go}}== |