kentaroi

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 current Process.group_leader/0 in Erlang

(IO — Elixir v1.16.0)

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 Pragmatic Bookshelf topics Top

iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
edruder
I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here. ...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
leonW
I ran this command after installing the sample application: $ cards add do something --owner Brian And got a file not found error: Fil...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New

Other popular topics Top

AstonJ
Or looking forward to? :nerd_face:
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New

Latest in PragProg Customers

View all threads ❯