really thanks Bert ;)<br>clear explanation... I had dome vague ideas but thats far clearer now<br><br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
A module is written in C (though often the C code is generated from<br>Squeak code) and needs to be compiled with a C compiler. Some modules<br>are linked into the VM, some are external. You can list all currently<br>used modules using &quot;Smalltalk listLoadedModules&quot;.
</blockquote><div><br>SmalltalkImage current listLoadedModules <br>for me on 3.9<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
To access a function from a C library without the need to write a<br>module, we have FFI primitives:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts: aString<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;cdecl: void 'puts' (char*) module: 'libSystem.dylib'&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^ExternalFunction externalCallFailed
<br><br>When called, FFI looks up the function &quot;puts&quot; in &quot;libSystem.dylib&quot;,<br>converts the Smalltalk string to a C char*, and calls the function with<br>it. This is for Mac OS X, on Linux, you would use &quot;
libc.so.1&quot; and on<br>Windows, I don't know, maybe &quot;system32.dll&quot; - FFI calls are very<br>platform-specific. Also, they can crash Squeak easily. That's the reason<br>the basic Squeak system does not use FFI at all, it is used for specific
<br>applications only, which have to deal with the platform issues.</blockquote><div><br>ok :) <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
So primitives generally are the gateway to the world outside Smalltalk's<br>objects.<br><br>Additionally, some primitives are optional, they are only used to speed<br>up lengthy computations. Like searching in a string or adding large
<br>numbers (ever tried &quot;1000 factorial&quot; ?).</blockquote><div><br>yes :)<br>thought it was 100% object power . A bit dissapointed ;) <br><br>euhh actually, I don't see any primitive call in Integer&gt;&gt;factorial , only a recursive function... did I miss somrthing ?
<br><br><br>Integer&gt;&gt;factorial<br>&nbsp;&nbsp;&nbsp; &quot;Answer the factorial of the receiver.&quot;<br><br>&nbsp;&nbsp;&nbsp; self = 0 ifTrue: [^ 1].<br>&nbsp;&nbsp;&nbsp; self &gt; 0 ifTrue: [^ self * (self - 1) factorial].<br>&nbsp;&nbsp;&nbsp; self error: 'Not valid for negative integers'
<br><br>Thanks again Bert<br><br>Cédrick<br><br><br>ps: Considering pragma, is there any classical uses that can be interesting to do to work at the meta level... like Id' like to tag instance variables according to their meaning in my application. I have no idea on how to use pragma for that...
<br></div></div>