Advertisement
Guest User

Untitled

a guest
Dec 17th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.28 KB | None | 0 0
  1. | convention | what it means/when to use |
  2. |-------------------------+-------------------------------------------|
  3. | V v | V is primitive, dynamic arr, assoc array, |
  4. | | COW, or kown copy cheap (< 16 bytes) |
  5. | | |
  6. | const(V) v | same as (V v), pedantic - makes copy and |
  7. | | guarantees no mutation in function |
  8. | | |
  9. | immutable(V) v | No need - for ensuring no local changes |
  10. | | prefer 'const(V) v' |
  11. | | |
  12. | ref V v | Use only when mutation of v is required |
  13. | | |
  14. | ref const(V) v | Indicate v will not be changed, accepts |
  15. | | {V, const(V), immutable(V)} |
  16. | | |
  17. | ref immutable(V) v | No need - restrictive with no benefit |
  18. | | over 'ref const(V) v' |
  19. | | |
  20. | V* v | Use only when mutation of v is required. |
  21. | | Prefer 'ref V v' unless null significant |
  22. | | or unsafe manipulations desired |
  23. | | |
  24. | const(V)* v | Indicate v will not be changed, |
  25. | | accepts {V*, const(V)*, immutable(V)*} |
  26. | | still prefer ref unless null significant |
  27. | | or unsafe manipulations desired |
  28. | | |
  29. | immutable(V)* v | No need - restrictive with no benefit |
  30. | | over 'const(V)* v' |
  31. | | |
  32. | T t | T is primitive, dynamic array, or assoc |
  33. | | array (i.e. cheap/shallow copies). For |
  34. | | generic code no knowledge of COW or |
  35. | | cheapness so prefer 'ref T t' |
  36. | | |
  37. | const(T) t | same as (T t), pedantic - makes copy and |
  38. | | guarantees no mutation in function |
  39. | | |
  40. | immutable(T) t | No need - for ensuring no local changes |
  41. | | prefer 'const(V) v' |
  42. | | |
  43. | ref T t | Use only when mutation of t is required |
  44. | | prefer 'ref const(T) t' if mutation not |
  45. | | required |
  46. | | |
  47. | ref const(T) t | Indicate t will not be changed, accepts |
  48. | | {T, const(T), immutable(T)} without copy |
  49. | | |
  50. | ref immutable(T) t | No need - restrictive with no benefit |
  51. | | over 'ref const(T) t' |
  52. | | |
  53. | auto ref T t | Use only when mutation of t required and |
  54. | | want support of by value for rvalues |
  55. | | (May be obviated in the long run) |
  56. | | |
  57. | auto ref const(T) t | Indicate t will not be changed, accepts |
  58. | | [lr]value {T, const(T), immutable(T)} |
  59. | | (May be obviated in the long run) |
  60. | | |
  61. | auto ref immutable(T) t | No need - restrictive with no benefit |
  62. | | over 'auto ref const(T) t' |
  63. | | |
  64. | T* t | Use only when mutation of t is required. |
  65. | | Prefer 'ref T t' unless null is |
  66. | | significant or dealing with unsafe code. |
  67. | | |
  68. | const(T)* t | Prefer 'ref const(T) t' unless |
  69. | | null is significant or dealing with |
  70. | | unsafe code |
  71. | | |
  72. | immutable(T)* t | No need - restrictive with no benefit |
  73. | | over 'const(T)* t' |
  74. | | |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement