Inline external function calls
An external language function can be called directly from a method using the following syntax:
<callingConvention: returnType 'library':function parameterTypes> code...
For example:
send: msg to: id
<c: int32 'message':sendTo int32 int32>
^self primitiveFailed
External language functions have the same syntax as those in PlatformFunction, with one exception. If the function called is in the user primitive table and not in a shared library, omit the references to the library. Thus, change the previous example as follows:
send: msg to: id
<c: int32 sendTo int32 int32>
^self primitiveFailed
The receiver of the method is not used in the function call. The number of arguments to the method must be the same as the number of parameters specified in the external function call. If callingConvention: specifies a returnType of void or none, the Smalltalk method returns the nil.
If the call to the external function fails (for the reasons described in Error cases), the fail code (the rest of the code in the method) is run. If no fail code is provided, self is returned on failure. The suggested default fail code is ^self primitiveFailed. It generates a walkback describing the reason for the failure and displaying the operating system error.
Last modified date: 11/05/2019