Small simplifications.

This commit is contained in:
José Valim
2011-02-04 00:06:36 +01:00
parent d8635abd5b
commit fbaa1dbf7b
4 changed files with 4 additions and 13 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ object Atom
%
% TODO Use bit syntax here
def inspect
String.new "#{"'"}#{Erlang.erlang.atom_to_binary(self, 'utf8)}"
String.new "#{"'"}#{Erlang.atom_to_binary(self, 'utf8)}"
end
% Convert an atom to a string.
@@ -19,6 +19,6 @@ object Atom
% 'A.to_s % => "A"
%
def to_s
String.new Erlang.erlang.atom_to_binary(self, 'utf8)
String.new Erlang.atom_to_binary(self, 'utf8)
end
end
+1 -3
View File
@@ -24,13 +24,11 @@ object List
Erlang.list_to_binary(self)
end
% Simply returns self. This method does not ensure the current
% list is really a char list.
def to_char_list
self
end
def length
Erlang.erlang.length(self)
Erlang.length(self)
end
end
+1 -1
View File
@@ -40,7 +40,7 @@ object String
% "josé".length % => 4
%
def length
Erlang.erlang.length(Erlang.unicode.characters_to_list(@bin, 'utf8))
Erlang.length(Erlang.unicode.characters_to_list(@bin, 'utf8))
end
% Returns the list representation of this String.
-7
View File
@@ -33,13 +33,6 @@ load_file(Filepath, Bindings) ->
{ok, String} = file:read_file(Filepath),
eval(binary_to_list(String), Bindings, Filepath).
% Read each line as UTF8.
read_line(Device, Accum) ->
case io:get_line(Device, []) of
eof -> file:close(Device), lists:flatten(lists:reverse(Accum));
Line -> read_line(Device, [Line|Accum])
end.
% Evaluates a string
eval(String) -> eval(String, []).
eval(String, Binding) -> eval(String, Binding, "nofile").