Skip to content

Commit

Permalink
Use |NimSkull| in the new text. Fix formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoomRmc committed Dec 12, 2021
1 parent 2630c7b commit c4a4a12
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions doc/tut1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -879,26 +879,26 @@ whose value is then returned implicitly.
Funcs and methods
-----------------

As mentioned in the introduction, Nim differentiates between procedures,
As mentioned in the introduction, |NimSkull| differentiates between procedures,
functions, and methods, defined by the `proc`, `func`, and `method` keywords
respectively. In some ways, Nim is a bit more pedantic in its definitions than
other languages.
respectively. In some ways, |NimSkull| is a bit more pedantic in its definitions
than other languages.

Functions are essentially procedures with additional limitations set on them:
they can't access global state (except `const`) and can't produce side-effects.
This puts Nim functions closer to the concept of a mathematical function, which
might be familiar to you if you've ever done functional programming. The main
benefit of the imposed limits is that it's much easier to reason about the code
with minimized interdependence of its various parts, as data flows directly
This puts |NimSkull| functions closer to the concept of a mathematical function,
which might be familiar to you if you've ever done functional programming. The
main benefit of the imposed limits is that it's much easier to reason about the
code with minimized interdependence of its various parts, as data flows directly
through a function from its arguments to its output. The other notable advantage
is that the self-contained nature of a function makes it inherently more
portable and easier to test.

Even though these benefits apply to Nim functions, it's important to keep in
mind that a `func` can still change its mutable arguments: those marked as `var`
along with `ref` objects (which possess interior mutability). This still allows
functions to have additional outputs beside the return value, making them not as
"pure" as their mathematical counterparts.
Even though these benefits apply to |NimSkull| functions, it's important to keep
in mind that a `func` can still change its mutable arguments: those marked as
`var` along with `ref` objects (which possess interior mutability). This still
allows functions to have additional outputs beside the return value, making them
not as "pure" as their mathematical counterparts.

Technically, the `func` keyword is a shorthand alias for `proc` tagged with
`{.noSideEffects.}`.
Expand Down

0 comments on commit c4a4a12

Please sign in to comment.