apis.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <!-- This file is generated by Nim. -->
  4. <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>API naming design</title>
  9. <!-- Google fonts -->
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  11. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  12. <!-- Favicon -->
  13. <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
  14. <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
  15. <!-- CSS -->
  16. <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
  17. <!-- JS -->
  18. <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
  19. </head>
  20. <body>
  21. <div class="document" id="documentId">
  22. <div class="container">
  23. <h1 class="title">API naming design</h1>
  24. <p>The API is designed to be <strong>easy to use</strong> and consistent. Ease of use is measured by the number of calls to achieve a concrete high-level action.</p>
  25. <h1 id="naming-scheme">Naming scheme</h1><p>The library uses a simple naming scheme that makes use of common abbreviations to keep the names short but meaningful. Since version 0.8.2 many symbols have been renamed to fit this scheme. The ultimate goal is that the programmer can <em>guess</em> a name.</p>
  26. <table border="1" class="docutils"><tr><th>English word</th><th>To use</th><th>Notes</th></tr>
  27. <tr><td>initialize</td><td>initT </td><td><tt class="docutils literal"><span class="pre"><span class="Identifier">init</span></span></tt> is used to create a value type <tt class="docutils literal"><span class="pre"><span class="Identifier">T</span></span></tt></td></tr>
  28. <tr><td>new</td><td>newP </td><td><tt class="docutils literal"><span class="pre"><span class="Identifier">new</span></span></tt> is used to create a reference type <tt class="docutils literal"><span class="pre"><span class="Identifier">P</span></span></tt></td></tr>
  29. <tr><td>find</td><td>find</td><td>should return the position where something was found; for a bool result use <tt class="docutils literal"><span class="pre"><span class="Identifier">contains</span></span></tt></td></tr>
  30. <tr><td>contains</td><td>contains</td><td>often short for <tt class="docutils literal"><span class="pre"><span class="Identifier">find</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">&gt;=</span> <span class="DecNumber">0</span></span></tt></td></tr>
  31. <tr><td>append</td><td>add</td><td>use <tt class="docutils literal"><span class="pre"><span class="Identifier">add</span></span></tt> instead of <tt class="docutils literal"><span class="pre"><span class="Identifier">append</span></span></tt></td></tr>
  32. <tr><td>compare</td><td>cmp</td><td>should return an int with the <tt class="docutils literal"><span class="pre"><span class="Operator">&lt;</span> <span class="DecNumber">0</span></span></tt> <tt class="docutils literal"><span class="pre"><span class="Operator">==</span> <span class="DecNumber">0</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Operator">&gt;</span> <span class="DecNumber">0</span></span></tt> semantics; for a bool result use <tt class="docutils literal"><span class="pre"><span class="Identifier">sameXYZ</span></span></tt></td></tr>
  33. <tr><td>put</td><td>put, <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Punctuation">]</span><span class="Operator">=</span></span></tt></td><td>consider overloading <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Punctuation">]</span><span class="Operator">=</span></span></tt> for put</td></tr>
  34. <tr><td>get</td><td>get, <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Punctuation">]</span></span></tt></td><td>consider overloading <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Punctuation">]</span></span></tt> for get; consider to not use <tt class="docutils literal"><span class="pre"><span class="Identifier">get</span></span></tt> as a prefix: <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> instead of <tt class="docutils literal"><span class="pre"><span class="Identifier">getLen</span></span></tt></td></tr>
  35. <tr><td>length</td><td>len</td><td>also used for <em>number of elements</em></td></tr>
  36. <tr><td>size</td><td>size, len</td><td>size should refer to a byte size</td></tr>
  37. <tr><td>capacity</td><td>cap</td><td></td></tr>
  38. <tr><td>memory</td><td>mem</td><td>implies a low-level operation</td></tr>
  39. <tr><td>items</td><td>items</td><td>default iterator over a collection</td></tr>
  40. <tr><td>pairs</td><td>pairs</td><td>iterator over (key, value) pairs</td></tr>
  41. <tr><td>delete</td><td>delete, del</td><td>del is supposed to be faster than delete, because it does not keep the order; delete keeps the order</td></tr>
  42. <tr><td>remove</td><td>delete, del</td><td>inconsistent right now</td></tr>
  43. <tr><td>remove-and-return</td><td>pop</td><td><tt class="docutils literal"><span class="pre"><span class="Identifier">Table</span></span></tt>/<tt class="docutils literal"><span class="pre"><span class="Identifier">TableRef</span></span></tt> alias to <tt class="docutils literal"><span class="pre"><span class="Identifier">take</span></span></tt></td></tr>
  44. <tr><td>include</td><td>incl</td><td></td></tr>
  45. <tr><td>exclude</td><td>excl</td><td></td></tr>
  46. <tr><td>command</td><td>cmd</td><td></td></tr>
  47. <tr><td>execute</td><td>exec</td><td></td></tr>
  48. <tr><td>environment</td><td>env</td><td></td></tr>
  49. <tr><td>variable</td><td>var</td><td></td></tr>
  50. <tr><td>value</td><td>value, val </td><td>val is preferred, inconsistent right now</td></tr>
  51. <tr><td>executable</td><td>exe</td><td></td></tr>
  52. <tr><td>directory</td><td>dir</td><td></td></tr>
  53. <tr><td>path</td><td>path</td><td>path is the string &quot;/usr/bin&quot; (for example), dir is the content of &quot;/usr/bin&quot;; inconsistent right now</td></tr>
  54. <tr><td>extension</td><td>ext</td><td></td></tr>
  55. <tr><td>separator</td><td>sep</td><td></td></tr>
  56. <tr><td>column</td><td>col, column </td><td>col is preferred, inconsistent right now</td></tr>
  57. <tr><td>application</td><td>app</td><td></td></tr>
  58. <tr><td>configuration</td><td>cfg</td><td></td></tr>
  59. <tr><td>message</td><td>msg</td><td></td></tr>
  60. <tr><td>argument</td><td>arg</td><td></td></tr>
  61. <tr><td>object</td><td>obj</td><td></td></tr>
  62. <tr><td>parameter</td><td>param</td><td></td></tr>
  63. <tr><td>operator</td><td>opr</td><td></td></tr>
  64. <tr><td>procedure</td><td>proc</td><td></td></tr>
  65. <tr><td>function</td><td>func</td><td></td></tr>
  66. <tr><td>coordinate</td><td>coord</td><td></td></tr>
  67. <tr><td>rectangle</td><td>rect</td><td></td></tr>
  68. <tr><td>point</td><td>point</td><td></td></tr>
  69. <tr><td>symbol</td><td>sym</td><td></td></tr>
  70. <tr><td>literal</td><td>lit</td><td></td></tr>
  71. <tr><td>string</td><td>str</td><td></td></tr>
  72. <tr><td>identifier</td><td>ident</td><td></td></tr>
  73. <tr><td>indentation</td><td>indent</td><td></td></tr>
  74. </table>
  75. <div class="twelve-columns footer">
  76. <span class="nim-sprite"></span>
  77. <br>
  78. <small style="color: var(--hint);">Made with Nim. Generated: 2025-01-09 11:59:35 UTC</small>
  79. </div>
  80. </div>
  81. </div>
  82. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  83. </body>
  84. </html>