{"id":4495,"date":"2016-01-07T12:59:13","date_gmt":"2016-01-07T12:59:13","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=4495"},"modified":"2016-01-09T17:57:46","modified_gmt":"2016-01-09T17:57:46","slug":"modula-gnu-modula-2","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=4495","title":{"rendered":"Modula-2 \/ Modula-3"},"content":{"rendered":"<h3>General<\/h3>\n<p><a href=\"http:\/\/www.modula2.org\/\">Modula-2<\/a><br \/>\n<a href=\"http:\/\/www.modula3.org\/\">Modula-3<\/a><br \/>\n<a href=\"http:\/\/nongnu.org\/gm2\/\">GNU Modula-2 (gm2)<\/a><br \/>\n<a href=\"http:\/\/www.opencm3.net\/\">Critical Mass Modula-3 (CM3)<\/a><\/p>\n<h3>Tutorials<\/h3>\n<p><a href=\"http:\/\/freepages.modula2.org\/index.html\"><\/a><\/p>\n<h3>Libraries<\/h3>\n<h3>FAQ<\/h3>\n<h4>Question<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ gm2 -g hello.mod\r\n\/usr\/bin\/ld: cannot find -lpth\r\ncollect2: error: ld returned 1 exit status\r\n<\/pre>\n<h4>Answer<\/h4>\n<p><a href=\"https:\/\/lists.gnu.org\/archive\/html\/gm2\/2011-03\/msg00006.html\">[Gm2] Re: still won&#8217;t compile and link<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ sudo apt-get install libpth-dev\r\n&#x5B;...]\r\nThe following NEW packages will be installed:\r\n  libpth-dev libpth20\r\n&#x5B;...]\r\n\r\n$ gm2 -g hello.mod\r\n&lt;no output&gt;\r\n<\/pre>\n<h4>Question<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ gm2 -o hello -g hello.mod\r\nfailed to find definition module InOut.def\r\n<\/pre>\n<h4>Answer<\/h4>\n<p>Every compiler has other libraries with exactly the same functions\/procedures:<\/p>\n<ul>\n<li>InOut (ulm)<\/li>\n<li>Terminal2<\/li>\n<li>StrIO<\/li>\n<\/ul>\n<pre class=\"brush: plain; title: GNU Modula-2 libraries; notranslate\" title=\"GNU Modula-2 libraries\">\r\n$ ls -la \/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\/\r\ntotal 48\r\ndrwxr-xr-x 8 root root  4096 Jan  7 13:43 .\r\ndrwxr-xr-x 8 root root  4096 Jan  7 13:43 ..\r\ndrwxr-xr-x 2 root root  4096 Jan  7 13:43 cor\r\ndrwxr-xr-x 2 root root 12288 Jan  7 13:43 iso\r\ndrwxr-xr-x 2 root root  4096 Jan  7 13:43 log\r\ndrwxr-xr-x 2 root root  4096 Jan  7 13:43 min\r\ndrwxr-xr-x 2 root root  4096 Jan  7 13:43 pim\r\ndrwxr-xr-x 2 root root 12288 Jan  7 13:43 ulm\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ sed -i -e 's\/InOut\/StrIO\/g' hello.mod\r\n$ gm2 -o hello -g hello.mod\r\n&lt;no output&gt;\r\n\r\nor\r\n\r\n$ gm2 -flibs=ulm,pim -o hello -g hello.mod\r\n<\/pre>\n<h4>Question<\/h4>\n<p>There is no procedure &#8220;RealRandomNumbers&#8221;<\/p>\n<h4>Answer<\/h4>\n<p>Only in &#8220;Stony Brook Modula-2&#8221; or the successor &#8220;ADW Modula-2&#8221; there is a procedure &#8220;RealRandomNumbers&#8221;.<br \/>\n<a href=\"http:\/\/www.terraterra.ch\/modula-2\/sb-m2-v4.html\">Stony Brook Modula-2 Development System<\/a><br \/>\n<a href=\"http:\/\/modula2.org\/sb\/indexw.html\">Stony Brook Software Home Page<\/a><br \/>\n<a href=\"http:\/\/www.modula2.org\/sb\/env\/index82.htm\">modula2.org: Stony Brook Modula-2<\/a><\/p>\n<p>There is a library to generate random numbers:<br \/>\n<a href=\"http:\/\/www.mathematik.uni-ulm.de\/modula\/man\/man3\/RandomGenerator.html\">Ulm&#8217;s Modula-2 Library: RandomGenerator<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ grep -r Random \/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\r\n\/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\/iso\/RandomNumber.def\r\n\/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\/log\/Random.def\r\n\/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\/ulm\/RandomGenerator.def\r\n<\/pre>\n<h4>Question<\/h4>\n<p>There are no string procedures (like Length or IntToStr).<\/p>\n<h4>Answer<\/h4>\n<p><a href=\"http:\/\/www.modula2.org\/reference\/isomodules\/\">ISO Modula-2 Modules Reference<\/a><\/p>\n<p><a href=\"http:\/\/www.excelsior-usa.com\/doc\/xds\/isolib01.html\">Input\/Output<\/a><\/p>\n<p><a href=\"http:\/\/www.excelsior-usa.com\/doc\/xds\/isolib05.html\">String Conversions<\/a><\/p>\n<blockquote><p>The string conversions library allows the conversion of the values of numeric data types to and from character string representations. The modules WholeStr, RealStr, and LongStr provide simple high-level facilities for converting to and from strings and whole number and real number data types. Low-level facilities are provided by the corresponding modules WholeConv, RealConv, and LongConv. Common data types and values that are used in the definition modules are defined by the module ConvTypes. <\/p><\/blockquote>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nFROM WholeStr   IMPORT IntToStr, CardToStr;\r\nFROM RealStr    IMPORT RealToStr;\r\n\r\nFROM \r\n<\/pre>\n<p>Use additional libraries (= modules)<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ grep -r &quot;PROCEDURE Length&quot; \/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\r\n\/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\/iso\/M2RTS.def\r\n\/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\/iso\/Strings.def\r\n\/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\/iso\/RealConv.def\r\n\/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\/log\/Strings.def\r\n\/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\/ulm\/M2RTS.mod\r\n\r\n$ gm2 -flibs=iso,pim -g -c MyLib.mod\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ grep -r &quot;PROCEDURE StrToInt&quot; \/opt\/gm2\/lib\/gcc\/x86_64-linux-gnu\/4.7.4\/m2\r\niso\/WholeStr.def:PROCEDURE StrToInt (str: ARRAY OF CHAR; VAR int: INTEGER;\r\niso\/WholeStr.mod:PROCEDURE StrToInt (str: ARRAY OF CHAR; VAR int: INTEGER;\r\nulm\/StrToNum.mod:   PROCEDURE StrToInt(str: ARRAY OF CHAR; VAR integ: INTEGER): BOOLEAN;\r\nulm\/StrToNum.def:   PROCEDURE StrToInt(str: ARRAY OF CHAR; VAR integ: INTEGER): BOOLEAN;\r\npim\/NumberIO.mod:PROCEDURE StrToInt (a: ARRAY OF CHAR ; VAR x: INTEGER) ; FORWARD ;\r\npim\/NumberIO.mod:PROCEDURE StrToInt (a: ARRAY OF CHAR ; VAR x: INTEGER) ;\r\npim\/NumberIO.def:PROCEDURE StrToInt (a: ARRAY OF CHAR ; VAR x: INTEGER) ;\r\n\r\n$ vi Main.mod\r\n&#x5B;...]\r\nFROM WholeStr   IMPORT IntToStr, CardToStr;\r\n&#x5B;...]\r\n\r\n$ gm2 -flibs=iso,pim -g -c Main.mod\r\n<\/pre>\n<h4>Question<\/h4>\n<p>How to use files<\/p>\n<h4>Answer<\/h4>\n<pre class=\"brush: plain; title: logitech \/ ulm; notranslate\" title=\"logitech \/ ulm\">\r\nlog\/InOut.def\r\nulm\/InOut.def\r\nFiles.def\r\n<\/pre>\n<p><a href=\"https:\/\/gist.github.com\/be9\/15282\/ab5f607e011cd735024952d7d5fa76c43b45442a\">Modula-2 &#8220;cat&#8221; in ISO-style<\/a><\/p>\n<pre class=\"brush: plain; title: iso; notranslate\" title=\"iso\">\r\niso\/StreamFile\r\niso\/ChanConsts\r\niso\/STextIO\r\niso\/TextIO\r\niso\/IOConsts\r\niso\/IOChan\r\n<\/pre>\n<h4>Dynamic Strings<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\npim\/DynamicStrings.def\r\n\r\nDEFINITION MODULE DynamicStrings ;\r\n\r\n(* Description: provides a dynamic string type and common methods. *)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>General Modula-2 Modula-3 GNU Modula-2 (gm2) Critical Mass Modula-3 (CM3) Tutorials Libraries FAQ Question $ gm2 -g hello.mod \/usr\/bin\/ld: cannot find -lpth collect2: error: ld returned 1 exit status Answer [Gm2] Re: still won&#8217;t compile and link $ sudo apt-get install libpth-dev &#x5B;&#8230;] The following NEW packages will be installed: libpth-dev libpth20 &#x5B;&#8230;] $ gm2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4495","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4495"}],"version-history":[{"count":21,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4495\/revisions"}],"predecessor-version":[{"id":4535,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4495\/revisions\/4535"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}