SVI hai 3 meses
pai
achega
06a9415dbf
Modificáronse 3 ficheiros con 23 adicións e 24 borrados
  1. 2 2
      doc/part01/ch09.md
  2. 20 22
      doc/part01/ch10.md
  3. 1 0
      doc/part01/main.md

+ 2 - 2
doc/part01/ch09.md

@@ -1,6 +1,6 @@
 # Глава 9. Шаблоны
 
-Что происходит, когда происходит вызывов `putPixel` для координат, выходящих за границы экрана? Это зависит от реализации библиотеки пикселей, но возможны три варианта:
+Что происходит, когда происходит вызовов `putPixel` для координат, выходящих за границы экрана? Это зависит от реализации библиотеки пикселей, но возможны три варианта:
 
 - 1 Ничего.
 - 2 Возникает исключение.
@@ -20,7 +20,7 @@ proc safePutPixel(x, y: int; col: Color) =
     putPixel(x, y, col) # 3
 ```
 
-- 1 Для простоты предположем, что разрешение экрана составляет 1024x768. С помощью `const` можно объявлять константы. Константа похожа на переменную, но её значение нельзя изменить, оно должно быть задано во время компиляции. Преимущества этих ограничений будут приведены позже.
+- 1 Для простоты предположим, что разрешение экрана составляет 1024x768. С помощью `const` можно объявлять константы. Константа похожа на переменную, но её значение нельзя изменить, оно должно быть задано во время компиляции. Преимущества этих ограничений будут приведены позже.
 - 2 Если координаты выходят за пределы допустимого диапазона, вернуть их.
 - 3 В противном случае вызвать процедуру `putPixel`.
 

+ 20 - 22
doc/part01/ch10.md

@@ -1,28 +1,26 @@
 # Chapter 10. Macros
 
-As we have seen templates can be used for tasks where ordinary procs fail.
-In some sense a template is more powerful than a proc. A macro is even
-more powerful than a template because a macro can inspect a body of code
-that is passed to it.
-The first macro can be very hard to understand because you don’t write the
-pattern that is expanded where the macro is invoked as you would for a
-template. Instead you write the instructions on how to create the pattern that
-is the code that is inserted where the macro is invoked.
+As we have seen templates can be used for tasks where ordinary procs fail. In some sense a template is more powerful than a proc. A macro is even more powerful than a template because a macro can inspect a body of code that is passed to it.
+
+The first macro can be very hard to understand because you don’t write the pattern that is expanded where the macro is invoked as you would for a template. Instead you write the instructions on how to create the pattern that is the code that is inserted where the macro is invoked.
+
 In other words the code is rather imperative and low level.
-The following example is a macro that turns the body of code that it receives
-into an empty list of statements (newStmtList()). This means that the body of
-code is ignored by the compiler:
-  import std / macros 1
-  macro disable(body: untyped): untyped = 2
-    result = newStmtList() 3
-  disable: 4
+
+The following example is a macro that turns the body of code that it receives into an empty list of statements (newStmtList()). This means that the body of code is ignored by the compiler:
+
+```nim
+  import std/macros                       # 1
+  macro disable(body: untyped): untyped = # 2
+    result = newStmtList()                # 3
+  disable:                                # 4
     drawText(10, 10, "Disabled piece of code!", Blue)
- 1 To work with macros an API is required, this API is in std/macros.
- 2 The macro declaration looks like the template declaration except that the
-     keyword template was replaced by macro.
- 3 The result of the macro is a syntax tree that is an empty list of statements.
- 4 To invoke a macro, the same syntax is used as for procs and templates.
-                                                                             43
+```
+
+- 1 To work with macros an API is required, this API is in std/macros.
+- 2 The macro declaration looks like the template declaration except that the keyword template was replaced by macro.
+- 3 The result of the macro is a syntax tree that is an empty list of statements.
+- 4 To invoke a macro, the same syntax is used as for procs and templates.
+
 Many more examples for macros can be found throughout the book but the
 better examples are too advanced for this introduction.
-And with this our first tour through Nim ends. Time to dive into the foxhole!
+And with this our first tour through Nim ends. Time to dive into the foxhole!

+ 1 - 0
doc/part01/main.md

@@ -9,3 +9,4 @@
 - [Глава 7](./ch07.md)
 - [Глава 8](./ch08.md)
 - [Глава 9](./ch09.md)
+- [Глава 10](./ch10.md)