apis.rst 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. include incl
  42. exclude excl
  43. command cmd
  44. execute exec
  45. environment env
  46. variable var
  47. value value, val val is preferred, inconsistent right
  48. now
  49. executable exe
  50. directory dir
  51. path path path is the string "/usr/bin" (for
  52. example), dir is the content of
  53. "/usr/bin"; inconsistent right now
  54. extension ext
  55. separator sep
  56. column col, column col is preferred, inconsistent right
  57. now
  58. application app
  59. configuration cfg
  60. message msg
  61. argument arg
  62. object obj
  63. parameter param
  64. operator opr
  65. procedure proc
  66. function func
  67. coordinate coord
  68. rectangle rect
  69. point point
  70. symbol sym
  71. literal lit
  72. string str
  73. identifier ident
  74. indentation indent
  75. ------------------- ------------ --------------------------------------