Giter VIP home page Giter VIP logo

elixir-in-action's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elixir-in-action's Issues

Question: Default argument example explanation

Hi,

I'm working my way through your book - it's been great so far. Thanks.

I have reached chapter 2, page 28 where it is written that:

You can set the defaults for any combination of arguments:

defmodule MyModule do
  def fun(a, b \\ 1, c, d \\ 2) do
    a+b+c+d
  end
end

Always keep in mind that default values generate multiple functions of the same name
with different arities. So the previous code generates three functions: MyModule.fun/2,
MyModule.fun/3, and MyModule.fun/4.

It is clear to me how the /2 and /4 arity functions would be generated. But there are two options for the /3 arity function - how does it generate one function which satisfies both conditions?

Ch-05 Correction in Listing 5.12 (todo_server.ex)

Again, this is a synthesis of techniques you’ve seen previously. You send a message and wait for the response. In the corresponding process_message/2 clause, you delegate to TodoList, and then you send the response and return the unchanged to-do list. This is needed because loop/2 takes the result of process_message/2 as the new state.

In the above paragraph, loop/2 should be replaced with loop/1 as there is no loop function in this module with an arity of 2.

Benchmark in section 10.1 returning strange values

Hi,

the benchmark in elixir_in_action_code_samples/ch10/profile_cache is returning the following results

$ iex -S mix
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Interactive Elixir (1.5.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Profiler.run(PageCache, 100000)

304625 reqs/sec

:ok
iex(2)> Profiler.run(PageCache, 100000, 100)

528910 reqs/sec

:ok
iex(3)>

Here are some more data:

iex(9)> Profiler.run(PageCache, 100000, 2)

305392 reqs/sec

:ok
iex(10)> Profiler.run(PageCache, 100000, 4)

389874 reqs/sec

:ok
iex(11)> Profiler.run(PageCache, 100000, 8)

324331 reqs/sec

:ok
iex(12)> Profiler.run(PageCache, 100000, 16)

360170 reqs/sec

:ok
iex(14)> Profiler.run(PageCache, 100000, 32)

381613 reqs/sec

:ok
iex(15)> Profiler.run(PageCache, 100000, 64)

460793 reqs/sec

:ok
iex(16)> Profiler.run(PageCache, 100000, 128)

534101 reqs/sec

:ok
iex(17)> Profiler.run(PageCache, 100000, 256)

543486 reqs/sec

:ok
iex(18)>

These are strange as instead of decreasing as in the book, the throughput is increasing?!
What am I doing wrong here?

I am with a Macbook Pro, 2.6 GHz Intel Core i5, 16 GB 1600 MHz DDR3, macOS Sierra 10.12.6, Erlang 20.2 and Elixir 1.5.2.

I had to change the code of the example to use Map instead of HashDict and to depend on Elixir 1.5.2 in mix.exs.

Thanks

[ch09] - ProcessRegistry restarts crash the App

In Chapter 09, section 9.1, the following code on iex

Todo.System.start_link
Process.exit(Process.whereis(Todo.ProcessRegistry),:kill)

causes the Supervisor to crash(after trying to restart the children). Trying to inspect the result of Registry.start_link, it shows

{:error,
 {:shutdown,
  {:failed_to_start_child, Todo.ProcessRegistry.PIDPartition0,
   {:already_started, #PID<0.183.0>}}}}

Am guessing that this happens because the supervisor is starting ProcessRegistry in succession before the actual Registry is shutdown and keeps erroring 3 times, ending up in shutdown.
Is that correct?
How to handle this scenario gracefully?

unnecessary setting in the ets example

:ets.new(:ets_page_cache, [:set, :named_table, :protected])

:protected is not necessary because it is the default. Also, the book says in chapter 10:

Finally, you opt for protected access because you’ll synchronize cache writes in the cache process. This means only client process must be able to write to the table, but all processes must have read access.

Shouldn't it go,

This means only the cache process must be able to write to the table, but all processes out have read access?

Reference to MyProject.start without introducing it first on page 61

In page 61, when discussing the use of Mix, there is the sentence

"Starts the system; terminates as soon as MyProject.start finishes"

but "MyProject.start" was not introduced before.

Perhaps the introduction of Mix should be deferred until OTP applications are discussed to make the use of Mix more clear to the reader.

SimpleRegistry links to itself?

Dear Saša,

I was going through the GenServer implementation of SimpleRegistry and am puzzled by this line in your example.

GenServer.call(__MODULE__, {:register, key, self()})

This registers the same SimpleRegistry's process's pid for any given key.

I think the intention was to create a new linked Process, something like

{:ok, pid} = Agent.start_link(fn -> %{} end) 

and register it in the parent SimpleRegistry.

Am I missing anything?

Thanks,
Oda

database cannot replicated via Elixir 1.9.2 version

Erlang/OTP 22 [erts-10.5.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

In this elixir version does not work.
Try to start two nodes in my macbook, by the following steps:
node1 : iex --sname node1@localhost -S mix
node2: iex --erl "-todo port 5555" --sname node2@localhost -S mix
in other terminal test add entries:
curl -d "" "http://localhost:5454/add_entry?list=bob&date=2018-12-19&title=Movies"
curl "http://localhost:5555/entries?list=bob&date=2018-12-19"
the curl command return empty, and the local folder in node2 is empty too.

Error running `:observer.start()` command (macOS)

Hi, First of all, thank you for an amazing book. I'm pretty into it.

I have a problem regarding chapter - working with components.
In section 11.2.3 - Visualizing the system, I have run the :observer.start() command, but the window doesn't appear (it actually flashes out).

The terminal fulls of huge cpp errors, like

/src/common/object.cpp(251): assert "classTable->Get(m_className) == NULL" failed in Register(): Class "wxMouseCaptureLostEvent" already in RTTI table - have you used IMPLEMENT_DYNAMIC_CLASS() multiple times or linked some object file twice)?

I am using macOS Big Sur and install elixir through brew.
Is there anything I need to install to make it works?
Thank you.

Great book!

I wanted to congratulate Sasa for the great book.
I just loved It!

Bump Elixir version numbers in `mix.exs`

I've been going through the book today and used this repo quite a lot. One thing that is annoying is that when you run iex -S mix I get an error because the mix files say elixir: "~> 1.0.0".

I can take care of this in a PR if you want :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.