{"id":928,"date":"2018-05-27T07:19:53","date_gmt":"2018-05-27T01:49:53","guid":{"rendered":"http:\/\/www.rangakrish.com\/?p=928"},"modified":"2018-06-06T14:00:38","modified_gmt":"2018-06-06T08:30:38","slug":"calling-go-functions-from-lisp","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2018\/05\/27\/calling-go-functions-from-lisp\/","title":{"rendered":"Calling Go Functions from Lisp"},"content":{"rendered":"<p>For the past few weeks I was travelling in the USA and had the pleasure of meeting several friends, some of whom are senior developers and architects. It was interesting to learn that many of them were either using <a href=\"https:\/\/golang.org\" target=\"_blank\" rel=\"noopener\"><em><strong>Go<\/strong><\/em> language<\/a> in their daily work, or were passionately endorsing the language! Due to lack of time, I had not looked at the language so far, but having returned to Chennai, I decided to devote some time to learning the language. After going through the basic language features, which definitely impress me for their simplicity and uniformity, I wanted to see how I could interface <em><strong>Go<\/strong><\/em> with my other favourite language, <em><strong>Lisp<\/strong><\/em>. That is the focus of today&#8217;s post. Please note that I am not going to discuss the language in any detail; there are several good books and tutorials for that.<\/p>\n<p>There are two parts to interfacing <em><strong>Go<\/strong><\/em> with <em><strong>Lisp<\/strong><\/em> &#8211; calling <em><strong>Go<\/strong><\/em> from <em><strong>Lisp<\/strong><\/em> and vice versa. Today, I will describe calling <em><strong>Go<\/strong><\/em> from <em><strong>Lisp<\/strong><\/em>. The other direction, namely from <em><strong>Go<\/strong><\/em> to <em><strong>Lisp<\/strong><\/em>,<span class=\"Apple-converted-space\">\u00a0 <\/span>will be part of a future article.<\/p>\n<p>What makes mixing <em><strong>Go<\/strong><\/em> with other languages possible is that there is a well-defined procedure for interfacing <em><strong>Go<\/strong><\/em> with <em><strong>C<\/strong><\/em>. So any language that can interoperate with <em><strong>C<\/strong><\/em>, can technically interact with <em><strong>Go<\/strong><\/em> as well.<\/p>\n<p>I found <a href=\"https:\/\/medium.com\/learning-the-go-programming-language\/calling-go-functions-from-other-languages-4c7d8bcc69bf\" target=\"_blank\" rel=\"noopener\">this article<\/a>\u00a0to be a good starting point.<\/p>\n<p>A brief description about my dev environment is in order here. I am using <em><strong>Windows 10<\/strong><\/em> and my Lisp is <a href=\"http:\/\/www.lispworks.com\" target=\"_blank\" rel=\"noopener\"><em><strong>LispWorks (64 bit) Enterprise Edition<\/strong><\/em><\/a>. There are several IDEs for <em><strong>Go<\/strong><\/em> but I chose <a href=\"https:\/\/ide.atom.io\" target=\"_blank\" rel=\"noopener\"><em><strong>Atom<\/strong><\/em><\/a> with two plug-ins: <em><strong>go-plus<\/strong><\/em> (<em><strong>Go<\/strong><\/em> package) and <em><strong>platformio-ide-terminal<\/strong><\/em> (<em><strong>Terminal<\/strong><\/em> package). The latter facilitates building and running <em><strong>Go<\/strong><\/em> from the IDE. As part of installing <em><strong>Go<\/strong><\/em> system on my <em><strong>Windows<\/strong><\/em>, I configured the <em><strong>GOPATH<\/strong><\/em> environment variable to point to my <em><strong>Go<\/strong><\/em> workspace directory. Finally, although I use <em><strong>Microsoft Visual Studio<\/strong><\/em> for my <em><strong>C++<\/strong><\/em> development, I stuck with <em><strong>GCC<\/strong><\/em> (as part of <em><strong>MinGW<\/strong><\/em>) for the purpose of this project.<\/p>\n<p>I decided to keep the code very minimal because the focus is not on the language itself. So here is the <em><strong>Go<\/strong><\/em> program that <em><strong>exports<\/strong><\/em> a function called <em><strong>addInt<\/strong><\/em> to be called by another language, in this case, <em><strong>Lisp<\/strong><\/em>.<\/p>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">package main<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">import &#8220;C&#8221;<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/export addInt<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">func addInt(a, b int64) int64 {<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">return a + b<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">}<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">func main() {<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">}<\/span><\/div>\n<p>Two things are quite important here:<\/p>\n<p style=\"padding-left: 30px;\">1) You have to include <em><strong>import &#8220;C&#8221;<\/strong><\/em> (<em><strong>C<\/strong><\/em> is called a pseudo package)<\/p>\n<p style=\"padding-left: 30px;\">2) The functions that need to be exported should have <em><strong>\/\/export &lt;function name&gt;<\/strong><\/em> annotation before their definition. Note also that there is no space after <em><strong>&#8220;<\/strong><strong>\/\/&#8221;<\/strong><\/em>.<\/p>\n<p>I explicitly used <em><strong>int64<\/strong><\/em> as the argument and return type to make sure the code works correctly across the language boundaries (my Lisp is also 64 bit). Other than this, there is nothing else to explain in the code. The source file is <em><strong>Example.go<\/strong><\/em> and is saved under <em><strong>&#8220;..\\Go Projects\\src\\C-export\\&#8221;<\/strong><\/em> directory (<em><strong>&#8220;Go Projects&#8221;<\/strong><\/em> is my workspace directory, pointed to by <em><strong>GOPATH<\/strong><\/em> environment variable).<\/p>\n<p>The next step is to compile this file. Run the following command from a separate command prompt or from the IDE terminal:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">&gt; go build -o Example.lib -buildmode=c-shared Example.go<\/span><\/p>\n<p>This will generate <em><strong>Example.lib<\/strong><\/em> and <em><strong>Example.h<\/strong><\/em>. The header file contains several <em><strong>Go<\/strong><\/em> to <em><strong>C<\/strong><\/em> type mappings, and the exported function signature. The following figure shows a part of the emitted file:<\/p>\n<figure id=\"attachment_930\" aria-describedby=\"caption-attachment-930\" style=\"width: 549px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/Header-file.png\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"930\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2018\/05\/27\/calling-go-functions-from-lisp\/header-file\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/Header-file.png\" data-orig-size=\"549,432\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Part of Header File\" data-image-description=\"&lt;p&gt;Part of Header File&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Part of Header File&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/Header-file.png\" class=\"size-full wp-image-930\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/Header-file.png?resize=549%2C432\" alt=\"Part of Header File\" width=\"549\" height=\"432\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/Header-file.png?w=549&amp;ssl=1 549w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/Header-file.png?resize=300%2C236&amp;ssl=1 300w\" sizes=\"(max-width: 549px) 100vw, 549px\" \/><\/a><figcaption id=\"caption-attachment-930\" class=\"wp-caption-text\"><strong>Part of Header File<\/strong><\/figcaption><\/figure>\n<p>What next? If we want to call this function from a <em><strong>C<\/strong><\/em> program, it is enough to link <em><strong>Example.lib<\/strong><\/em> with the rest of the <em><strong>C<\/strong><\/em> code. However, we want to call this function from <em><strong>Lisp<\/strong><\/em>. <em><strong>LispWorks<\/strong><\/em> (on Windows) supports calling foreign language functions, as long as they are bundled as a <em><strong>DLL<\/strong><\/em>. Since there is no way (that I know of) to compile the <em><strong>Go<\/strong><\/em> module into a <em><strong>DLL<\/strong><\/em>, we need another layer. We define a <em><strong>C<\/strong><\/em> file that acts as a stub\/wrapper for the actual <em><strong>Go<\/strong><\/em> function, and compile this file into a <em><strong>DLL<\/strong><\/em>. Note this introduces an additional function call overhead, but that seems unavoidable.<\/p>\n<p>Here is the stub file <em><strong>Example-wrapper.c<\/strong><\/em>:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">#include &#8220;Example.h&#8221;<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">__declspec(dllexport) GoInt64 addIntWrapper(GoInt64 a, GoInt64 b){<\/span><br \/>\n<span style=\"color: #0000ff;\">\u00a0 \u00a0 \u00a0 \u00a0return addInt(a, b);<\/span><br \/>\n<span style=\"color: #0000ff;\">}<\/span><\/p>\n<p>Note the <em><strong>__declspec(dllexport)<\/strong><\/em> decoration on the stub function. This is needed to export the function in our <em><strong>DLL<\/strong><\/em>. Also, as a good practice (even though it is not required for use with <em><strong>LispWorks<\/strong><\/em>), we declare the exported function in a separate header file <em><strong>Example-wrapper.h<\/strong><\/em>.<\/p>\n<p>Now we can compile this file into a <em><strong>DLL<\/strong><\/em>, linking it with <em><strong>Example.lib<\/strong><\/em>:<\/p>\n<p><span class=\"Apple-converted-space\">\u00a0 \u00a0 <\/span><span style=\"color: #0000ff;\">&gt; gcc -c Example-wrapper.c<\/span><\/p>\n<p><span style=\"color: #0000ff;\"><span class=\"Apple-converted-space\">\u00a0 \u00a0 <\/span>&gt; gcc -shared -o Example-wrapper.dll Example-wrapper.o Example.lib<\/span><\/p>\n<p>It is a good idea to make sure the <em><strong>DLL<\/strong><\/em> contains our exported function. I used the tool <a href=\"http:\/\/www.nirsoft.net\/utils\/dll_export_viewer.html\" target=\"_blank\" rel=\"noopener\"><em><strong>dllexp-x64<\/strong><\/em><\/a> for this purpose. See the screen shot:<\/p>\n<figure id=\"attachment_932\" aria-describedby=\"caption-attachment-932\" style=\"width: 626px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/DLL-Viewer.png\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"932\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2018\/05\/27\/calling-go-functions-from-lisp\/dll-viewer\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/DLL-Viewer.png\" data-orig-size=\"626,473\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"DLL Viewer\" data-image-description=\"&lt;p&gt;DLL Viewer&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;DLL Viewer&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/DLL-Viewer.png\" class=\"size-full wp-image-932\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/DLL-Viewer.png?resize=626%2C473\" alt=\"DLL Viewer\" width=\"626\" height=\"473\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/DLL-Viewer.png?w=626&amp;ssl=1 626w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/05\/DLL-Viewer.png?resize=300%2C227&amp;ssl=1 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><figcaption id=\"caption-attachment-932\" class=\"wp-caption-text\"><strong>DLL Viewer<\/strong><\/figcaption><\/figure>\n<p>For use in another language environment, we have to distribute the files <em><strong>Example.lib<\/strong><\/em>, and <em><strong>Example-wrapper.dll<\/strong><\/em>. For use with a <em><strong>C\/C++<\/strong><\/em> program, we also need <em><strong>Example.h<\/strong><\/em> and <em><strong>Example-wrapper.h<\/strong><\/em>.<\/p>\n<p>Let us now come to the <em><strong>LispWorks<\/strong><\/em> part. Calling foreign functions (on <em><strong>Windows<\/strong><\/em> platform, defined in a <em><strong>DLL<\/strong><\/em> ) is fairly straightforward. Here is the code:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">(in-package &#8220;CL-USER&#8221;)<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">(hcl:change-directory &#8220;G:\/LispWorks Projects\/Ranga\/Golang\/Interfacing with Go&#8221;)<\/span><br \/>\n<span style=\"color: #0000ff;\">(fli:register-module &#8220;Example-wrapper.DLL&#8221;)<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">(fli:define-foreign-function (add-int-wrapper &#8220;addIntWrapper&#8221; :source)<\/span><br \/>\n<span style=\"color: #0000ff;\">\u00a0 \u00a0 ((x :int64)<\/span><br \/>\n<span style=\"color: #0000ff;\">\u00a0 \u00a0 (y :int64))<\/span><br \/>\n<span style=\"color: #0000ff;\">\u00a0 \u00a0 :result-type :int64<\/span><br \/>\n<span style=\"color: #0000ff;\">\u00a0 \u00a0 :language :ansi-c)<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">(defun test-go-function (arg1 arg2)<\/span><br \/>\n<span style=\"color: #0000ff;\">\u00a0 \u00a0 (declare (int64 arg1) (int64 arg2))<\/span><br \/>\n<span style=\"color: #0000ff;\">\u00a0 \u00a0 (format t &#8220;Sum of ~d and ~d is: ~d~%&#8221; arg1 arg2 (add-int-wrapper arg1 arg2)))<\/span><\/p>\n<p>Since we have copied <em><strong>Example.lib<\/strong><\/em> and <em><strong>Example-wrapper.dll<\/strong><\/em> to the current project directory, we switch to that directory (otherwise it is necessary to include the\u00a0<em><strong>DLL<\/strong><\/em> location in <em><strong>PATH<\/strong><\/em> environment variable). The function <em><strong>define-foreign-function<\/strong><\/em> allows us to declare the signature of the foreign function, in this case, the wrapper function available in the <em><strong>DLL<\/strong><\/em>. You can see that I have declared the parameters and return type as <em><strong>int64<\/strong><\/em> so that it is consistent with the <em><strong>Go<\/strong><\/em> function signature.<\/p>\n<p>The function <em><strong>test-go-functio<\/strong><\/em>n calls our wrapper function to compute the result. The wrapper, in turn, calls the actual <em><strong>Go<\/strong><\/em> function. That is it!<\/p>\n<p>We can evaluate this expression to see the result:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">CL-USER 1 &gt; (test-go-function 250 350)<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">Sum of 250 and 350 is: 600<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">NIL<\/span><\/p>\n<p>Perfect! Works as expected.<\/p>\n<p>Hope I have explained in sufficient detail the process of calling <em><strong>Go<\/strong><\/em> function from <em><strong>LispWorks<\/strong><\/em>. There could be minor differences with respect to other Lisp environments, but it should not be hard to get things working.<\/p>\n<p>Please note that calls across language runtime boundaries are fairly expensive, so they should be used only if justified. For me, <em><strong>Go<\/strong><\/em> is a new language in my toolkit, and I really enjoyed learning it!<\/p>\n<p>Have fun!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For the past few weeks I was travelling in the USA and had the pleasure of meeting several friends, some of whom are senior developers and architects. It was interesting to learn that many of them were either using Go language in their daily work, or were passionately endorsing the language! Due to lack of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[141,18,17],"tags":[143,142,19,99],"class_list":["post-928","post","type-post","status-publish","format-standard","hentry","category-golang","category-lisp","category-programming","tag-foreign-functions","tag-go-language","tag-lisp","tag-lispworks"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-eY","jetpack-related-posts":[{"id":2927,"url":"https:\/\/www.rangakrish.com\/index.php\/2022\/10\/20\/why-learn-lisp\/","url_meta":{"origin":928,"position":0},"title":"Why Learn Lisp?","author":"admin","date":"October 20, 2022","format":false,"excerpt":"In the last article, I had shared my views on why programmers should learn Prolog, preferably as the first language. What language should one learn next? I strongly pitch for Lisp, to be precise, \u201cCommon Lisp\u201d. Lisp happens to be the second oldest (1958) programming language, only after Fortran (1957)!\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2645,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/12\/25\/calling-lisp-functions-from-d-language\/","url_meta":{"origin":928,"position":1},"title":"Calling Lisp Functions from D Language","author":"admin","date":"December 25, 2021","format":false,"excerpt":"After exploring \"newLisp\" in the past few posts, I would like to start looking at the \"D Programming Language\"\u00a0(DLang). DLang\u00a0has been around since 2001. It was originally created by Walter Bright and later Andrei Alexandrescu joined the team in 2007. The main inspiration for DLang was C++, although it uses\u2026","rel":"","context":"In &quot;D Language&quot;","block_context":{"text":"D Language","link":"https:\/\/www.rangakrish.com\/index.php\/category\/d-language\/"},"img":{"alt_text":"Lisp Function Called from D","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":944,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/06\/10\/calling-lisp-functions-from-go-language\/","url_meta":{"origin":928,"position":2},"title":"Calling Lisp Functions from Go Language","author":"admin","date":"June 10, 2018","format":false,"excerpt":"In the previous post, we saw how to invoke a Go function from Lisp. In today's post, I would like to explain how to go in the other direction, namely, how to call Lisp functins from Go. There are two ways to do this. The first approach is to load\u2026","rel":"","context":"In &quot;Golang&quot;","block_context":{"text":"Golang","link":"https:\/\/www.rangakrish.com\/index.php\/category\/golang\/"},"img":{"alt_text":"Direct DLL Call","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/06\/LispCall.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/06\/LispCall.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/06\/LispCall.png?resize=525%2C300 1.5x"},"classes":[]},{"id":963,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/06\/24\/calling-go-functions-from-lisp-part-2\/","url_meta":{"origin":928,"position":3},"title":"Calling Go Functions from Lisp &#8211; Part 2","author":"admin","date":"June 24, 2018","format":false,"excerpt":"In my earlier article Calling Go Functions from Lisp, I explained the steps for making calls to Go functions from another language, specifically LispWorks Lisp. Today, I want to give a slightly more\u00a0 interesting example showing the use of Go channels\u00a0through exported functions. Go is widely admired for its native\u2026","rel":"","context":"In &quot;Golang&quot;","block_context":{"text":"Golang","link":"https:\/\/www.rangakrish.com\/index.php\/category\/golang\/"},"img":{"alt_text":"Go Functions","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/06\/Go-Functions.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2057,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/07\/19\/calling-lisp-functions-from-elixir\/","url_meta":{"origin":928,"position":4},"title":"Calling Lisp Functions from Elixir","author":"admin","date":"July 19, 2020","format":false,"excerpt":"In the last article\u00a0I showed how we can simulate the idea of Lisp's \"closure\" in Elixir. Today, I would like to demonstrate how we can call Lisp functions from Elixir using the NIF interface. What is the need to integrate Elixir with another language? I can think of two reasons:\u2026","rel":"","context":"In &quot;Elixir&quot;","block_context":{"text":"Elixir","link":"https:\/\/www.rangakrish.com\/index.php\/category\/elixir\/"},"img":{"alt_text":"Using the Lisp Functions","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":3070,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/04\/02\/building-v-language-dll\/","url_meta":{"origin":928,"position":5},"title":"Building V Language DLL","author":"admin","date":"April 2, 2023","format":false,"excerpt":"The relatively new V Programming Language (Vlang) boasts of some interesting features such as \u201cfast compilation\u201d and runtime performance \u201cas fast as C\u201d, at the same time being a \u201csimple language\u201d. As I normally do with other languages that I learn and use, I decided to see how easy it\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.rangakrish.com\/index.php\/category\/programming\/"},"img":{"alt_text":"V Program","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/04\/V-source-267x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=928"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/928\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}