e011_version_0_9_4.rst 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. 2014-04-21 Version 0.9.4 released
  2. =================================
  3. .. container:: metadata
  4. Posted by Dominik Picheta on 21/04/2014
  5. The Nimrod development community is proud to announce the release of version
  6. 0.9.4 of the Nimrod compiler and tools. **Note: This release has to be
  7. considered beta quality! Lots of new features have been implemented but
  8. unfortunately some do not fulfill our quality standards yet.**
  9. Prebuilt binaries and instructions for building from source are available
  10. on the `download page <download.html>`_.
  11. This release includes about
  12. `1400 changes <https://github.com/Araq/Nimrod/compare/v0.9.2...v0.9.4>`_
  13. in total including various bug
  14. fixes, new languages features and standard library additions and improvements.
  15. This release brings with it support for user-defined type classes, a brand
  16. new VM for executing Nimrod code at compile-time and new symbol binding
  17. rules for clean templates.
  18. It also introduces support for the brand new
  19. `Babel package manager <https://github.com/nimrod-code/babel>`_ which
  20. has itself seen its first release recently. Many of the wrappers that were
  21. present in the standard library have been moved to separate repositories
  22. and should now be installed using Babel.
  23. Apart from that a new **experimental** Asynchronous IO API has been added via
  24. the ``asyncdispatch`` and ``asyncnet`` modules. The ``net`` and ``rawsockets``
  25. modules have also been added and they will likely replace the sockets
  26. module in the next release. The Asynchronous IO API has been designed to
  27. take advantage of Linux's epoll and Windows' IOCP APIs, support for BSD's
  28. kqueue has not been implemented yet but will be in the future.
  29. The Asynchronous IO API provides both
  30. a callback interface and an interface which allows you to write code as you
  31. would if you were writing synchronous code. The latter is done through
  32. the use of an ``await`` macro which behaves similar to C#'s await. The
  33. following is a very simple chat server demonstrating Nimrod's new async
  34. capabilities.
  35. .. code-block::nim
  36. import asyncnet, asyncdispatch
  37. var clients: seq[PAsyncSocket] = @[]
  38. proc processClient(client: PAsyncSocket) {.async.} =
  39. while true:
  40. let line = await client.recvLine()
  41. for c in clients:
  42. await c.send(line & "\c\L")
  43. proc serve() {.async.} =
  44. var server = newAsyncSocket()
  45. server.bindAddr(TPort(12345))
  46. server.listen()
  47. while true:
  48. let client = await server.accept()
  49. clients.add client
  50. processClient(client)
  51. serve()
  52. runForever()
  53. Note that this feature has been implemented with Nimrod's macro system and so
  54. ``await`` and ``async`` are no keywords.
  55. Syntactic sugar for anonymous procedures has also been introduced. It too has
  56. been implemented as a macro. The following shows some simple usage of the new
  57. syntax:
  58. .. code-block::nim
  59. import future
  60. var s = @[1, 2, 3, 4, 5]
  61. echo(s.map((x: int) => x * 5))
  62. A list of changes follows, for a comprehensive list of changes take a look
  63. `here <https://github.com/Araq/Nimrod/compare/v0.9.2...v0.9.4>`_.
  64. Library Additions
  65. -----------------
  66. - Added ``macros.genSym`` builtin for AST generation.
  67. - Added ``macros.newLit`` procs for easier AST generation.
  68. - Added module ``logging``.
  69. - Added module ``asyncdispatch``.
  70. - Added module ``asyncnet``.
  71. - Added module ``net``.
  72. - Added module ``rawsockets``.
  73. - Added module ``selectors``.
  74. - Added module ``asynchttpserver``.
  75. - Added support for the new asynchronous IO in the ``httpclient`` module.
  76. - Added a Python-inspired ``future`` module that features upcoming additions
  77. to the ``system`` module.
  78. Changes affecting backwards compatibility
  79. -----------------------------------------
  80. - The scoping rules for the ``if`` statement changed for better interaction
  81. with the new syntactic construct ``(;)``.
  82. - ``OSError`` family of procedures has been deprecated. Procedures with the same
  83. name but which take different parameters have been introduced. These procs now
  84. require an error code to be passed to them. This error code can be retrieved
  85. using the new ``OSLastError`` proc.
  86. - ``os.parentDir`` now returns "" if there is no parent dir.
  87. - In CGI scripts stacktraces are shown to the user only
  88. if ``cgi.setStackTraceStdout`` is used.
  89. - The symbol binding rules for clean templates changed: ``bind`` for any
  90. symbol that's not a parameter is now the default. ``mixin`` can be used
  91. to require instantiation scope for a symbol.
  92. - ``quoteIfContainsWhite`` now escapes argument in such way that it can be safely
  93. passed to shell, instead of just adding double quotes.
  94. - ``macros.dumpTree`` and ``macros.dumpLisp`` have been made ``immediate``,
  95. ``dumpTreeImm`` and ``dumpLispImm`` are now deprecated.
  96. - The ``nil`` statement has been deprecated, use an empty ``discard`` instead.
  97. - ``sockets.select`` now prunes sockets that are **not** ready from the list
  98. of sockets given to it.
  99. - The ``noStackFrame`` pragma has been renamed to ``asmNoStackFrame`` to
  100. ensure you only use it when you know what you're doing.
  101. - Many of the wrappers that were present in the standard library have been
  102. moved to separate repositories and should now be installed using Babel.
  103. Compiler Additions
  104. ------------------
  105. - The compiler can now warn about "uninitialized" variables. (There are no
  106. real uninitialized variables in Nimrod as they are initialized to binary
  107. zero). Activate via ``{.warning[Uninit]:on.}``.
  108. - The compiler now enforces the ``not nil`` constraint.
  109. - The compiler now supports a ``codegenDecl`` pragma for even more control
  110. over the generated code.
  111. - The compiler now supports a ``computedGoto`` pragma to support very fast
  112. dispatching for interpreters and the like.
  113. - The old evaluation engine has been replaced by a proper register based
  114. virtual machine. This fixes numerous bugs for ``nimrod i`` and for macro
  115. evaluation.
  116. - ``--gc:none`` produces warnings when code uses the GC.
  117. - A ``union`` pragma for better C interoperability is now supported.
  118. - A ``packed`` pragma to control the memory packing/alignment of fields in
  119. an object.
  120. - Arrays can be annotated to be ``unchecked`` for easier low level
  121. manipulations of memory.
  122. - Support for the new Babel package manager.
  123. Language Additions
  124. ------------------
  125. - Arrays can now be declared with a single integer literal ``N`` instead of a
  126. range; the range is then ``0..N-1``.
  127. - Added ``requiresInit`` pragma to enforce explicit initialization.
  128. - Exported templates are allowed to access hidden fields.
  129. - The ``using statement`` enables you to more easily author domain-specific
  130. languages and libraries providing OOP-like syntactic sugar.
  131. - Added the possibility to override various dot operators in order to handle
  132. calls to missing procs and reads from undeclared fields at compile-time.
  133. - The overload resolution now supports ``static[T]`` params that must be
  134. evaluable at compile-time.
  135. - Support for user-defined type classes has been added.
  136. - The *command syntax* is supported in a lot more contexts.
  137. - Anonymous iterators are now supported and iterators can capture variables
  138. of an outer proc.
  139. - The experimental ``strongSpaces`` parsing mode has been implemented.
  140. - You can annotate pointer types with regions for increased type safety.
  141. - Added support for the builtin ``spawn`` for easy thread pool usage.
  142. Tools improvements
  143. ------------------
  144. - c2nim can deal with a subset of C++. Use the ``--cpp`` command line option
  145. to activate.