Skip to content

Commit

Permalink
Clean up the code a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
alco committed Apr 26, 2012
1 parent ca34986 commit 71d0c78
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
9 changes: 8 additions & 1 deletion lib/dict/gen_dict.ex → lib/dict/common.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ defprotocol PDict, [
# PDict.put [a: 1, b: 2], {:c, 3}
# #=> [a: 1, b: 2, c: 3]
# """
put(dict, key, val),
put(dict, pair),
put(dict, key, val),

# @doc """
# Removes the entry stored under the given key from `dict`.
Expand Down Expand Up @@ -140,6 +140,13 @@ defmodule Dict.Common do
defmacro __using__(module, impl_ref) do
ref = Module.concat(PDict, impl_ref)
quote do
@doc """
Creates a new empty dict.
"""
def new do
unquote(ref).empty(nil)
end

@doc """
Creates a new dict with one entry.
"""
Expand Down
7 changes: 0 additions & 7 deletions lib/dict/dict.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,4 @@ end

defmodule Dict do
use Dict.Common, :Tuple

@doc """
Creates a new empty Dict.
"""
def new do
:dict.new
end
end
7 changes: 0 additions & 7 deletions lib/dict/orddict.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,4 @@ end

defmodule Orddict do
use Dict.Common, :List

@doc """
Creates a new empty Orddict.
"""
def new do
[]
end
end

0 comments on commit 71d0c78

Please sign in to comment.