@@ -147,7 +147,10 @@ defmodule IO do
147147 end
148148
149149 @ doc """
150- Gets `count` bytes from the IO device. It returns:
150+ Gets a number of bytes from the io device. If the
151+ io device is an unicode device, count implies
152+ the number of unicode codepoints to be retrieved.
153+ Otherwise, the number of raw bytes. It returns:
151154
152155 * `data` - The input characters.
153156
@@ -157,21 +160,43 @@ defmodule IO do
157160 for instance {:error, :estale} if reading from an
158161 NFS file system.
159162 """
163+ def getn ( prompt , count // 1 )
164+
165+ def getn ( prompt , count ) when is_integer ( count ) do
166+ getn ( group_leader , prompt , count )
167+ end
168+
169+ def getn ( device , prompt ) do
170+ getn ( device , prompt , 1 )
171+ end
172+
173+ @ doc """
174+ Gets a number of bytes from the io device. If the
175+ io device is an unicode device, count implies
176+ the number of unicode codepoints to be retrieved.
177+ Otherwise, the number of raw bytes.
178+ """
179+ def getn ( device , prompt , count ) do
180+ :io . get_chars ( map_dev ( device ) , to_iodata ( prompt ) , count )
181+ end
182+
183+ @ doc false
160184 def getb ( prompt , count // 1 )
161185
162186 def getb ( prompt , count ) when is_integer ( count ) do
163- getb ( group_leader , prompt , count )
187+ IO . write "[WARNING] IO.getb is deprecated, please use IO.getn instead\n #{ Exception . format_stacktrace } "
188+ getn ( prompt , count )
164189 end
165190
166191 def getb ( device , prompt ) do
167- getb ( device , prompt , 1 )
192+ IO . write "[WARNING] IO.getb is deprecated, please use IO.getn instead\n #{ Exception . format_stacktrace } "
193+ getn ( device , prompt )
168194 end
169195
170- @ doc """
171- Gets `count` bytes from the chosen IO device.
172- """
196+ @ doc false
173197 def getb ( device , prompt , count ) do
174- :io . get_chars ( map_dev ( device ) , to_iodata ( prompt ) , count )
198+ IO . write "[WARNING] IO.getb is deprecated, please use IO.getn instead\n #{ Exception . format_stacktrace } "
199+ getn ( device , prompt , count )
175200 end
176201
177202 @ doc """
0 commit comments