Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename to_list to to_char_list, closes #108

  • Loading branch information...
commit c1f46670d281a0c89ea07e611b18f62083b336a9 1 parent fc71d61
@josevalim josevalim authored
View
10 lib/code.ex
@@ -22,11 +22,11 @@ defmodule Code do
end
def append_path(path) do
- Erlang.code.add_pathz(to_list(path))
+ Erlang.code.add_pathz(to_char_list(path))
end
def prepend_path(path) do
- Erlang.code.add_patha(to_list(path))
+ Erlang.code.add_patha(to_char_list(path))
end
# Evalutes the quotes contents.
@@ -37,7 +37,7 @@ defmodule Code do
# Code.eval_quoted contents, [a: 1, b: 2], __FILE__, __LINE__ # => 3
#
def eval_quoted(quoted, binding, filename, line) do
- Erlang.elixir.eval_quoted [quoted], binding, line, to_list(filename)
+ Erlang.elixir.eval_quoted [quoted], binding, line, to_char_list(filename)
end
# Loads the given `file`. Accepts `relative_to` as an argument to tell
@@ -68,13 +68,13 @@ defmodule Code do
# Compiles `file` and returns a list of tuples where the first element
# is the module name and the second one is its binary.
def compile_file(file) do
- Erlang.elixir_compiler.file to_list(file)
+ Erlang.elixir_compiler.file to_char_list(file)
end
# Compiles `file` and add the result to the given `destination`.
# Destination needs to be a directory.
def compile_file_to_dir(file, destination) do
- Erlang.elixir_compiler.file_to_path to_list(file), to_list(destination)
+ Erlang.elixir_compiler.file_to_path to_char_list(file), to_char_list(destination)
end
# Get the stacktrace.
View
6 lib/elixir/builtin.ex
@@ -374,11 +374,11 @@ defmodule Elixir::Builtin do
#
# ## Examples
#
- # to_list(:foo)
+ # to_char_list(:foo)
# #=> 'foo'
#
- defmacro to_list(arg) do
- quote { ::List::Inspect.to_list(unquote(arg)) }
+ defmacro to_char_list(arg) do
+ quote { ::List::Inspect.to_char_list(unquote(arg)) }
end
# Define elem to get Tuple element according to Elixir conventions.
View
14 lib/list/inspect.ex
@@ -1,23 +1,23 @@
-defprotocol List::Inspect, [to_list(thing)],
+defprotocol List::Inspect, [to_char_list(thing)],
only: [BitString, List, Tuple, Atom]
defimpl List::Inspect, for: Atom do
- def to_list(atom), do: atom_to_list(atom)
+ def to_char_list(atom), do: atom_to_list(atom)
end
defimpl List::Inspect, for: BitString do
- def to_list(bitstring), do: bitstring_to_list(bitstring)
+ def to_char_list(bitstring), do: bitstring_to_list(bitstring)
end
defimpl List::Inspect, for: Tuple do
- def to_list(tuple), do: tuple_to_list(tuple)
+ def to_char_list(tuple), do: tuple_to_list(tuple)
end
defimpl List::Inspect, for: List do
- def to_list(list), do: list
+ def to_char_list(list), do: list
end
defimpl List::Inspect, for: Number do
- def to_list(integer) when is_integer(integer), do: integer_to_list(integer)
- def to_list(float) when is_float(float), do: float_to_list(float)
+ def to_char_list(integer) when is_integer(integer), do: integer_to_list(integer)
+ def to_char_list(float) when is_float(float), do: float_to_list(float)
end
View
10 lib/module.ex
@@ -1,6 +1,6 @@
-# We cannot use to_list because it depends on inspect,
+# We cannot use to_char_list because it depends on inspect,
# which depends on protocol, which depends on this module.
-import Elixir::Builtin, except: [to_list: 1]
+import Elixir::Builtin, except: [to_char_list: 1]
defmodule Module do
require Erlang.ets, as: ETS
@@ -19,7 +19,7 @@ defmodule Module do
#
def eval_quoted(module, quoted, binding, filename, line) do
assert_already_compiled!(:eval_quoted, module)
- { binding, scope } = Erlang.elixir_module.binding_and_scope_for_eval(line, to_list(filename), module, binding)
+ { binding, scope } = Erlang.elixir_module.binding_and_scope_for_eval(line, to_char_list(filename), module, binding)
Erlang.elixir_def.reset_last(module)
Erlang.elixir.eval_quoted([quoted], binding, line, scope)
end
@@ -173,8 +173,8 @@ defmodule Module do
defp kind_to_entry(:defp), do: :private
defp kind_to_entry(:defmacro), do: :macros
- defp to_list(list) when is_list(list), do: list
- defp to_list(bin) when is_binary(bin), do: binary_to_list(bin)
+ defp to_char_list(list) when is_list(list), do: list
+ defp to_char_list(bin) when is_binary(bin), do: binary_to_list(bin)
defp attribute_table_for(module) do
list_to_atom Erlang.lists.concat([:a, module])
View
8 test/elixir/list/inspect_test.exs
@@ -4,7 +4,7 @@ defmodule List::Inspect::AtomTest do
use ExUnit::Case
def test_basic do
- 'foo' = to_list(:foo)
+ 'foo' = to_char_list(:foo)
end
end
@@ -12,7 +12,7 @@ defmodule List::Inspect::BitStringTest do
use ExUnit::Case
def test_basic do
- 'foo' = to_list("foo")
+ 'foo' = to_char_list("foo")
end
end
@@ -20,7 +20,7 @@ defmodule List::Inspect::TupleTest do
use ExUnit::Case
def test_basic do
- [1, "b", 3] = to_list({ 1, "b", 3 })
+ [1, "b", 3] = to_char_list({ 1, "b", 3 })
end
end
@@ -28,6 +28,6 @@ defmodule List::Inspect::ListTest do
use ExUnit::Case
def test_basic do
- [1, "b", 3] = to_list([ 1, "b", 3 ])
+ [1, "b", 3] = to_char_list([ 1, "b", 3 ])
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.