apis.rst 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. =================
  2. API naming design
  3. =================
  4. The API is designed to be **easy to use** and consistent. Ease of use is
  5. measured by the number of calls to achieve a concrete high-level action.
  6. Naming scheme
  7. =============
  8. The library uses a simple naming scheme that makes use of common abbreviations
  9. to keep the names short but meaningful. Since version 0.8.2 many symbols have
  10. been renamed to fit this scheme. The ultimate goal is that the programmer can
  11. *guess* a name.
  12. ------------------- ------------ --------------------------------------
  13. English word To use Notes
  14. ------------------- ------------ --------------------------------------
  15. initialize initT ``init`` is used to create a
  16. value type ``T``
  17. new newP ``new`` is used to create a
  18. reference type ``P``
  19. find find should return the position where
  20. something was found; for a bool result
  21. use ``contains``
  22. contains contains often short for ``find() >= 0``
  23. append add use ``add`` instead of ``append``
  24. compare cmp should return an int with the
  25. ``< 0`` ``== 0`` or ``> 0`` semantics;
  26. for a bool result use ``sameXYZ``
  27. put put, ``[]=`` consider overloading ``[]=`` for put
  28. get get, ``[]`` consider overloading ``[]`` for get;
  29. consider to not use ``get`` as a
  30. prefix: ``len`` instead of ``getLen``
  31. length len also used for *number of elements*
  32. size size, len size should refer to a byte size
  33. capacity cap
  34. memory mem implies a low-level operation
  35. items items default iterator over a collection
  36. pairs pairs iterator over (key, value) pairs
  37. delete delete, del del is supposed to be faster than
  38. delete, because it does not keep
  39. the order; delete keeps the order
  40. remove delete, del inconsistent right now
  41. remove-and-return pop ``Table``/``TableRef`` alias to ``take``
  42. include incl
  43. exclude excl
  44. command cmd
  45. execute exec
  46. environment env
  47. variable var
  48. value value, val val is preferred, inconsistent right
  49. now
  50. executable exe
  51. directory dir
  52. path path path is the string "/usr/bin" (for
  53. example), dir is the content of
  54. "/usr/bin"; inconsistent right now
  55. extension ext
  56. separator sep
  57. column col, column col is preferred, inconsistent right
  58. now
  59. application app
  60. configuration cfg
  61. message msg
  62. argument arg
  63. object obj
  64. parameter param
  65. operator opr
  66. procedure proc
  67. function func
  68. coordinate coord
  69. rectangle rect
  70. point point
  71. symbol sym
  72. literal lit
  73. string str
  74. identifier ident
  75. indentation indent
  76. ------------------- ------------ --------------------------------------