New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
input_line is #3155
Comments
Comment author: administrator
I'm not too concerned about this, because it is fairly rare that more
Reasonable, although this could be written more concisely with
|
Comment author: administrator
I heve to write ACM-like programs, and i have some limits for execution
I have two requests/questions:
let add a b = a +. b;;val add : float -> float -> float = let add a b = a + b;;val add : int -> int -> int = add 3.5 4.5;;
add 3 4;;
? Lukasz Lew |
Comment author: administrator Date: Wed, 16 Jan 2002 17:37:02 +0100 (MET)
Just a note: I had to implement a slightly different version of Bruno. |
Comment author: administrator From: ll189417@zodiac.mimuw.edu.pl
You here try to overload the add identifier so that In your example, it is clear that "add" in add 3.5 4.5 should refer to let double x = add x x;;What the type of double ? Is it for integers, floats, or both ? Jun P. Furuse Jun.Furuse@inria.fr |
Comment author: administrator
Please read this code: let add = function let double x = add x x;; Am i right that we can emulate overloading with polymorphic variants? I can't clearly understand relationship between polymorphic variants and Does any functional languages have overloading? Uhh... so much questions..sorry :) Lukasz Lew |
Comment author: administrator On Wed, Jan 16, 2002 at 06:20:05PM +0100, Bruno.Verlyck@inria.fr wrote:
C'est un problème que j'ai déjà rencontré à plusieurs reprises. Peut-être faudrait-il un traitement spécial pour les objets de grande -- Jérôme |
Comment author: administrator
OK, I'm convinced :-) We will fix it one way or another. Bruno's
|
Comment author: administrator
En fait, meme en faisant tourner le compacteur, elles ne seront pas
Ce genre de bidouille implique generalement un overhead pas -- Damien |
Comment author: administrator I've been thinking about the problem with Pervasives.read_line. If you want to read arbitrary-length lines, not only it has quadratic I think we should set a reasonable limit (like 64k) to the line
As far as I can tell, it should have died with -- Damien |
Comment author: administrator Date: Wed, 23 Jan 2002 17:17:55 +0100 (MET) I've been thinking about the problem with Pervasives.read_line.
As far as I can tell, it should have died with Penses-tu le modifier (le comportement) ? Bruno. |
Comment author: administrator Reimplemented input_line 2002-02-11 XL |
Original bug ID: 813
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Lukasz Lew
Version: 3.04
OS: Win 2000
Submission from: 54-dzi-3.acn.waw.pl (62.121.66.54)
The read_line function from pervasives.ml is ineffective.
It is O(n^2) because cost of string concatenation. So i propose sth like this:
let input_line chan =
let rec input_line accu len =
let n = input_scan_line chan in
if n = 0 then raise End_of_file
else if n > 0 then begin
let res = string_create (n-1) in
ignore (unsafe_input chan res 0 (n-1));
ignore (input_char chan);
(len+n-1, (n-1, res) :: accu)
end else begin
let res = string_create (-n) in
ignore (unsafe_input chan res 0 (-n));
try input_line ((-n, res) :: accu) (len-n) with
End_of_file -> len, accu
end
in
let len, lst = input_line [] 0 in
let res = string_create len
and pos = ref len in
List.iter
(fun (len, str) -> pos := !pos - len; string_blit str 0 res !pos len)
lst;
res
This function at first reads blocks provided by unsafe_input
and push on list. And when total lenght is known it creates result string, copy
everything and retuns it.
The text was updated successfully, but these errors were encountered: