<thelema>
the right way is to use a 64-bit type to do the mult.
<thelema>
and to check if the result is out of bounds
<_zack>
for instance ... it looks like that Jun Furuse is now at Jane Street
<rwmjones_>
but if the method in the patch works, it's easier to understand
* thelema
wouldn't even consider xalloc_oversized's method
<thelema>
performance isn't too critical here, no? this is a 'once per PNG open' function, right?
<thelema>
because the -2, but the idea of dividing is sound.
* thelema
doesn't like because the -2
<rwmjones_>
performance is not critical at all here
<thelema>
ocaml batteries currently divides. It's more expensive than various bit-twiddling tricks, but it's sound.
<thelema>
you'll need a max_int constant.
<thelema>
(to divide)
<_zack>
rwmjones_: the patch looks fine to me (but I haven't verified if all occurrences have been catched), still I disagree that multiplying in 64-bit and then checking if there is an overflow would be harder to understand
<thelema>
I'd recommend not using the [-1 -> unsigned] trick.
<_zack>
why you think it will be less clear?
<_zack>
(maybe it'll be less efficient, but that's a different story)
<rwmjones_>
well, I'm going to push that patch as-is to Fedora now, and if anyone comes up with a better one, I'll push that later ...
<thelema>
int division is expensive. The current hack is just that - a hack.
<thelema>
but if X and Y are 32-bit values, it's not difficult to have an overflowed multiply be less than each of them.
<thelema>
your test for overflow is only probabilistic, thus no good.
<rwmjones_>
thelema, can you give a counterexample?
<thelema>
for example: (2^32 -2) * (2^32 -2)
<thelema>
I'm testing this at the moment
<thelema>
but I'd be really surprised if the result mod 2^32 was 2^32-1
<thelema>
rwmjones_: definitely important to use safe ints for this kind of thing
ertai has quit [Read error: 104 (Connection reset by peer)]
jeddhaberstro has joined #ocaml
mishok13 has quit ["Stopping IRC chat... [OK]"]
rwmjones_ has quit [Read error: 110 (Connection timed out)]
dabd has joined #ocaml
Submarine has quit [Remote closed the connection]
sporkmonger has joined #ocaml
<_andre>
in programs using the Toplevel module, is it possible somehow to use its generic printing function?
<_andre>
i don't see anything in the interface files, so i'm guessing it isn't...
<C_Tux>
_andre: what do you mean with "generic printing" ?
dabd has quit [Client Quit]
<_andre>
well, the toplevel can print results of any type
<C_Tux>
hmmm : "- : out_channel = <abstr>"
rwmjones_ has joined #ocaml
<_andre>
that's ok, what i mean is that it works for any type
_zack has quit ["Leaving."]
<_andre>
toploop.ml uses stuff from modules Typemod, Printtyp, etc
<_andre>
i'm not sure that's available to use
<julm>
_andre: have you had a glance at toplevellib.cma?
<_andre>
julm: no, is there any documentation for it?
<_andre>
or some mli file :)
<julm>
I can't find one.. except the sources..
<_andre>
outval_of_value in genprintval.ml looks like it...
<_andre>
i wonder if it's exported
<julm>
try to use cmigrep on the .cma
<_andre>
cmigrep, that's new to me :)
<_andre>
there's actually this in toploop.mli
<_andre>
val print_value: Env.t -> Obj.t -> formatter -> Types.type_expr -> unit
<julm>
I don't know how you can get the Env.t and the Types.type_expr..
<_andre>
neither do i :(
Yoric[DT] has quit ["Ex-Chat"]
<_andre>
and i don't think there would be a need for Std.dump in extlib if that was possible at all...
_zack has joined #ocaml
<_andre>
it seems i can get the Env.t with Toploop.toplevel_env
C_Tux is now known as DobbsHead
_PenPen_ has joined #ocaml
<thelema>
_andre: you don't like Std.dump?
<_andre>
thelema: i was in search of something to use in ospec, and Std.dump doesn't have enough type information, so things like [], None and 0 are all represented as 0
<_andre>
which can be quite confusing in a testing library output...
<thelema>
That's the best that can be done - what did you want?
<_andre>
i was hoping i could use the Toploop module and do whatever the toplevel does to print its output
<thelema>
the toplevel cheats because it knows the types of values
<_andre>
yeah, i wanted to do the same cheat :)
<thelema>
during compilation, types are erased, so at runtime, there's no type information.
<thelema>
you'd have to write your own runtime that preserves type information
<_andre>
because my program is actually a kind of toplevel
<_andre>
i run code through Toploop.execute_phrase
<_andre>
so i was hoping i could access that type information somehow
Associat0r has joined #ocaml
DobbsHead is now known as C_Tux
itewsh has joined #ocaml
xwm__ has joined #ocaml
xwm__ has quit [Client Quit]
kig has quit ["leaving"]
LeCamarade is now known as LeCamarade|Away
Submarine has joined #ocaml
itewsh has quit [Connection timed out]
itewsh has joined #ocaml
julm has quit [Read error: 104 (Connection reset by peer)]
julm has joined #ocaml
_zack has quit [Read error: 113 (No route to host)]
Yoric[DT] has joined #ocaml
astie has joined #ocaml
itewsh has quit [Connection timed out]
itewsh has joined #ocaml
mgodshal1 has joined #ocaml
julm has quit [Read error: 113 (No route to host)]
_andre has quit ["leaving"]
mgodshall has quit [Read error: 110 (Connection timed out)]
esope has joined #ocaml
jeddhaberstro has quit []
julm has joined #ocaml
esope has quit ["Leaving."]
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
C_Tux is now known as MichaelJackson
MichaelJackson is now known as C_Tux
bombshelter13_ has quit []
maxote2 has joined #ocaml
slash_ has joined #ocaml
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
maxote2 is now known as maxote
maskd- has joined #ocaml
komar_ has quit [Read error: 60 (Operation timed out)]
maskd- is now known as maskd
hkBst has quit [Read error: 104 (Connection reset by peer)]
Submarine has quit [Read error: 110 (Connection timed out)]
itewsh has quit ["There are only 10 kinds of people: those who understand binary and those who don't"]
astie has quit [Client Quit]
Yoric[DT] has quit ["Ex-Chat"]
_PenPen_ has quit ["Leaving"]
komar_ has joined #ocaml
thelema has quit [Read error: 110 (Connection timed out)]
slash_ has quit [Client Quit]
Associat0r has quit ["#proglangdesign #ltu ##concurrency"]