
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
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /react-native
- /v
- /wasm
- /django
- /security
- /nodejs
- /centos
- /rails
- /haskell
- /fable
- /gleam
- /js
- /swift
- /deno
- /tailwind
- /assemblyscript
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /c-plus-plus
- /preact
- /flutter
- /actix
- /java
- /angular
- /ocaml
- /kubuntu
- /zig
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /keyboards
- /html
- /emacs
- /nim
- /vuejs
- /elm
- /nerves