
kentaroi
Programming Elixir 1.6 - errata (page 227)
def puts(device \\ group_leader(), item) do
erl_dev = map_dev(device)
:io.put_chars erl_dev, [to_iodata(item), ?\n]
end
def puts(device \\ :stdio, item) do
:io.put_chars(map_dev(device), [to_chardata(item), ?\n])
end
The implementation of IO.puts
function in page 227 is outdated (elixir/lib/elixir/lib/io.ex at v1.6 · elixir-lang/elixir · GitHub).
The problem is the above code is the introduction of :erlang.group_leader
function, which is used later in page 227, but the implementation of IO.puts
in Elixir 1.4 and above does not use the :erlang.group_leader
function (Use :stdio instead of group_leader() as default device by michalmuskala · Pull Request #5089 · elixir-lang/elixir · GitHub).
By the way,
:stdio
- a shortcut for:standard_io
, which maps to
the currentProcess.group_leader/0
in Erlang
Therefore, although the default device of the IO.puts
function has changed to :stdio
, the erlang.group_leader()
function is still called in Erlang’s io
module and the behavior of the IO.puts
function was not changed by Use :stdio instead of group_leader() as default device by michalmuskala · Pull Request #5089 · elixir-lang/elixir · GitHub.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /centos
- /ash
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /lua
- /nodejs
- /c
- /julia
- /slackware
- /neovim