|
92 | 92 |
|
93 | 93 | <center>
|
94 | 94 | <h1 class="title">Code Patterns in newLISP<font size="-1">®</font>
|
95 |
| -</h1>Version 2015 July 11th<sup>rd</sup><br/> |
96 |
| -<a href="http://newlisp.org">newLISP</a> v.10.6.2 |
| 95 | +</h1>Version 2017 Augusr 11<sup>th</sup><br/> |
| 96 | +<a href="http://newlisp.org">newLISP</a> v.10.7.3 |
97 | 97 | </center>
|
98 | 98 |
|
99 | 99 | <br/><br/><br/>
|
@@ -2335,7 +2335,12 @@ <h3>Using <tt>exec</tt></h3>
|
2335 | 2335 | <p>This method is only suited for short exchanges, executing one command and receiving the output.</p>
|
2336 | 2336 |
|
2337 | 2337 | <pre>
|
2338 |
| -(exec "ls *.c") → ("." ".." "util.c" "example.ls") |
| 2338 | +> (exec "ls *.c") |
| 2339 | +("newlisp.c" "nl-debug.c" "nl-filesys.c" "nl-import.c" "nl-list.c" "nl-liststr.c" |
| 2340 | + "nl-math.c" "nl-matrix.c" "nl-sock.c" "nl-string.c" "nl-symbol.c" "nl-utf8.c" "nl-web.c" |
| 2341 | + "nl-xml-json.c" "pcre-chartables.c" "pcre.c" "unix-lib.c" "win-dll.c" "win-path.c" |
| 2342 | + "win-util.c") |
| 2343 | +> |
2339 | 2344 | </pre>
|
2340 | 2345 |
|
2341 | 2346 | <p>The <tt>exec</tt> function opens a process pipe for the Unix command-line utility <tt>ls</tt> and collects each line of STDOUT into a list of strings.</p>
|
@@ -3010,7 +3015,7 @@ <h3>Stateless server with inetd</h3>
|
3010 | 3015 |
|
3011 | 3016 | <p>After configuring <tt>inetd</tt> or <tt>xinetd</tt> either process must be restarted to re-read the configuration files. This can be accomplished by sending the Unix <tt>HUP</tt> signal to either the <tt>inetd</tt> or <tt>xinetd</tt> process using the Unix <tt>kill</tt> or Unix <tt>nohup</tt> utility.</p>
|
3012 | 3017 |
|
3013 |
| -<p>On Mac OS X the <tt>launchd</tt> facility can be used in a similar fashion. The newLISP source distribution contains the file <tt>org.newlisp.newlisp.plist</tt> in the <tt>util/</tt> directory. This file can be used to launch newlisp server during OS boot time as a persistent server.</p> |
| 3018 | +<p>On macOS the <tt>launchd</tt> facility can be used in a similar fashion. The newLISP source distribution contains the file <tt>org.newlisp.newlisp.plist</tt> in the <tt>util/</tt> directory. This file can be used to launch newlisp server during OS boot time as a persistent server.</p> |
3014 | 3019 |
|
3015 | 3020 | <h3>Test the server with telnet</h3>
|
3016 | 3021 |
|
@@ -3378,7 +3383,7 @@ <h3>Media types in HTTP modes</h3>
|
3378 | 3383 | <a name="toc-23"></a>
|
3379 | 3384 | <h2>23. Extending newLISP</h2>
|
3380 | 3385 |
|
3381 |
| -<p>newLISP has an import function, which allows importing function from DLLs (Dynamic Link Libraries) on Win32 or shared libraries on Linux/Unix (ending in .so, ending in .dylib on Mac OS X).</p> |
| 3386 | +<p>newLISP has an import function, which allows importing function from DLLs (Dynamic Link Libraries) on Win32 or shared libraries on Linux/Unix (ending in .so, ending in .dylib on macOS).</p> |
3382 | 3387 |
|
3383 | 3388 | <h3>Simple versus extended FFI interface</h3>
|
3384 | 3389 |
|
@@ -3439,7 +3444,7 @@ <h3>A shared library in C</h3>
|
3439 | 3444 |
|
3440 | 3445 | <h3>Compile on Unix</h3>
|
3441 | 3446 |
|
3442 |
| -<p>On Mac OS X and Linux/Unix we can compile and link <tt>testlib.so</tt> in one step:</p> |
| 3447 | +<p>On macOS and Linux/Unix we can compile and link <tt>testlib.so</tt> in one step:</p> |
3443 | 3448 |
|
3444 | 3449 | <pre>
|
3445 | 3450 | gcc testlib.c -shared -o testlib.so
|
@@ -3700,7 +3705,7 @@ <h3>Extracting return values</h3>
|
3700 | 3705 |
|
3701 | 3706 | <h3>Writing library wrappers</h3>
|
3702 | 3707 |
|
3703 |
| -<p>Sometimes the simple version of newLISP's built-in import facility cannot be used with a library. This happens whenever a library does not strictly adhere to <tt>cdecl</tt> calling conventions expecting all parameters passed on the stack. E.g. when running Mac OS X on older PPC CPUs instead of Intel CPUs, the OpenGL libraries installed by default on Mac OS X cannot be used.</p> |
| 3708 | +<p>Sometimes the simple version of newLISP's built-in import facility cannot be used with a library. This happens whenever a library does not strictly adhere to <tt>cdecl</tt> calling conventions expecting all parameters passed on the stack. E.g. when running macOS on older PPC CPUs instead of Intel CPUs, the OpenGL libraries installed by default on macOS cannot be used.</p> |
3704 | 3709 |
|
3705 | 3710 | <p>Since newLISP version 10.4.0, the problem can be solved easiest using the newer extended syntax of <tt>import</tt>, which automatically resolves platform and architectural differences. On very small systems or whenever the needed <tt>libffi</tt> system library is not present on a platform, a special wrapper library can be built to translate <tt>cdecl</tt> conventions expected by newLISP into the calling conventions expected by the target library.</p>
|
3706 | 3711 |
|
@@ -3801,7 +3806,7 @@ <h3>Registering callbacks in external libraries</h3>
|
3801 | 3806 | <h2>24. newLISP as a shared library</h2>
|
3802 | 3807 |
|
3803 | 3808 | <p>On all platforms, newLISP can be compiled as a shared library. On Win32, the library
|
3804 |
| -is called <tt>newlisp.dll</tt>, on Mac OS X <tt>newlisp.dylib</tt> and on Linux and |
| 3809 | +is called <tt>newlisp.dll</tt>, on macOS <tt>newlisp.dylib</tt> and on Linux and |
3805 | 3810 | BSDs, the library is called <tt>newlisp.so</tt>. Makefiles are included in the source
|
3806 | 3811 | distribution for most platforms. Only on Win32, the installer comes with a precompiled
|
3807 | 3812 | <tt>newlisp.dll</tt> and will install it in the <tt>Program Files/newlisp/</tt> directory.</p>
|
@@ -3934,7 +3939,7 @@ <h3>Registering callbacks</h3>
|
3934 | 3939 | </pre>
|
3935 | 3940 |
|
3936 | 3941 | <p>Note that Win32 and many Unix flavors will look for <tt>newlisp.dll</tt>
|
3937 |
| -in the system library path, but Mac OS X will look for <tt>newlisp.dylib</tt> |
| 3942 | +in the system library path, but macOS will look for <tt>newlisp.dylib</tt> |
3938 | 3943 | first in the current directory, if the full file path is not specified. The
|
3939 | 3944 | program above can also be found as <tt>callback</tt> in the source distribution
|
3940 | 3945 | in the <tt>newlisp-x.x.x/examples</tt> directory.</p>
|
|
0 commit comments