apis.rst 3.8 KB

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