Alpounet changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | 3.11.1 out now! Get yours from http://caml.inria.fr/ocaml/release.html - Answer OCaml Meeting 2010 poll https://forge.ocamlcore.org/survey/survey.php?group_id=77&survey_id=1
julm has joined #ocaml
sramsay_ has quit [Remote closed the connection]
ice_four_phone has quit []
morse has quit ["Ex-Chat"]
valross has joined #ocaml
thieusoai has quit ["leaving"]
tonyIII has joined #ocaml
peddie_ has joined #ocaml
seanmcl has quit []
seanmcl has joined #ocaml
peddie has quit [Read error: 113 (No route to host)]
seanmcl has quit []
peddie_ has quit [Remote closed the connection]
Associat0r has joined #ocaml
Amorphous has quit [Read error: 110 (Connection timed out)]
valross_ has quit [Remote closed the connection]
Amorphous has joined #ocaml
Ched has quit [Read error: 110 (Connection timed out)]
seanmcl has joined #ocaml
thrasibule has joined #ocaml
Associat0r has quit []
valross has quit [Remote closed the connection]
valross has joined #ocaml
seanmcl has quit []
caligula_ has joined #ocaml
duryodhan has joined #ocaml
<duryodhan> hi .. I am trying to write a simple program using OCAML and ExtLib .. but ocamlc says Unbound Module Extlib on open Extlib ;; .. how do I tell ocamlc that I have extlib ?
caligula__ has quit [Read error: 110 (Connection timed out)]
<Alpounet> duryodhan, pass "extlib.cma" to ocamlc when compiling
_unK has quit [Read error: 104 (Connection reset by peer)]
<duryodhan> Alpounet: I have the line open ExtLib at the top and passed extLib.cma to ocamlc and it says Unbound module ExtLib
<Alpounet> show your ocamlc call
<duryodhan> ocamlc /usr/lib/ocaml/3.10.2/extlib/extLib.cma 1.ml
<duryodhan> Alpounet: ?
tmaedaZ has quit [Read error: 60 (Operation timed out)]
<hcarty> duryodhan: Try "ocamlc -I +extlib extLib.cma 1.ml"
<hcarty> duryodhan: or "ocamlc -I /usr/lib/ocaml/3.10.2/extlib extLib.cma 1.ml"
tmaedaZ has joined #ocaml
ulfdoz has joined #ocaml
<duryodhan> hcarty: I still get reference to undefined global Str
Ched has joined #ocaml
ulfdoz has quit [Read error: 110 (Connection timed out)]
Ched has quit [Client Quit]
julm_ has joined #ocaml
ygrek_ has joined #ocaml
valross has quit [Read error: 110 (Connection timed out)]
tmaedaZ is now known as tmaeda
<duryodhan> this is insane .. this looks like such a trivial thing .. write and compile a program that uses extLib
<flux> duryodhan, you need str.cma
<flux> however, I would use ocamlfind. ocamlfind ocamlc -package extlib -linkpkg -o foo foo.ml
<duryodhan> flux: still the same error with ocamlfind
<flux> right. are you actually supposed to write open ExtLib?
<flux> because I'm thinking extlib doesn't come with module called ExtLib :)
ttamttam has joined #ocaml
<flux> rather it comes with modules like ExtList etc which you can open, and for example ExtList contains the ExtLib's version of the List module
<duryodhan> flux: tried without open ExtLib , then with open ExtStr both failed
<duryodhan> the first one gives the same old Str error
<flux> duryodhan, how about ExtString..
<duryodhan> and the second gives unbound module ExtStr
<flux> it doesn't come with ExtStr either
<flux> ls `ocamlfind query extlib`/*.cmi will list the modules extlib comes with
<duryodhan> yeah tried ExtString .. it says unbound module ExtString
<flux> I tried this: 1) echo 'open ExtString' > foo.ml 2) ocamlfind ocamlc -package extlib -linkpkg -o foo foo.ml 3) a binary 'foo' is created
<duryodhan> yeah
<duryodhan> same here
<duryodhan> one min
julm has quit [Read error: 110 (Connection timed out)]
<duryodhan> so I get Reference to undefined global Str
<flux> -package extlib,str
<duryodhan> AHA!
<duryodhan> :)
<flux> apparently extlib misses a dependency on str
<duryodhan> thanks!
<flux> if it's extlib code that uses str
<flux> duryodhan, happy coding :)
<duryodhan> yeah ..now I can actually go to coding instead of "how do I compile?"
<duryodhan> :D
Associat0r has joined #ocaml
Associat0r has quit [Read error: 104 (Connection reset by peer)]
mishok13 has joined #ocaml
rwmjones has joined #ocaml
tonyIII has quit [Read error: 110 (Connection timed out)]
tonyIII has joined #ocaml
kaustuv has joined #ocaml
tmaeda0 has joined #ocaml
tmaeda has quit [Read error: 110 (Connection timed out)]
ygrek_ has quit [Remote closed the connection]
gdmfsob has joined #ocaml
munga has joined #ocaml
_zack has joined #ocaml
Alpounet has quit [Read error: 104 (Connection reset by peer)]
mishok13 has quit [Read error: 110 (Connection timed out)]
gdmfsob is now known as mishok13
david has joined #ocaml
david is now known as Guest21457
Guest21457 is now known as Yoric
<Yoric> hi
det has quit [Remote closed the connection]
Submarine has joined #ocaml
<rwmjones> gildor, haven't looked at this in detail yet but:
<rwmjones> ocamlfind ocamlc -package "fileutils" -c gettextDomain.ml
<rwmjones> File "gettextDomain.ml", line 47, characters 2-15:
<rwmjones> Error: Unbound value make_filename
<rwmjones> make[2]: *** [gettextDomain.cmo] Error 2
<rwmjones> rm gettextMo_parser.mli gettextMo_parser.ml gettextMo_lexer.ml gettextFormat_parser.mli gettextFormat_parser.ml gettextLocale_parser.ml gettextFormat_lexer.ml gettextLocale_lexer.ml gettextLocale_parser.mli
<rwmjones> make[2]: Leaving directory `/home/rjones/d/fedora/ocaml-gettext/devel/ocaml-gettext-0.3.3/libgettext-ocaml'
<rwmjones> make[1]: *** [all] Error 2
julm has joined #ocaml
<rwmjones> ah, looks like it needs an update ocaml-fileutils package ... let me go and fix that one first
<rwmjones> gildor, no problem - building against fileutils 0.4.0 fixed that
julm_ has quit [Read error: 110 (Connection timed out)]
ygrek_ has joined #ocaml
tmaeda0 is now known as tmaedaZ
seanmcl has joined #ocaml
Yoric[DT] has joined #ocaml
Yoric has quit ["Leaving"]
Yoric[DT] has quit [Client Quit]
svenl has quit [Read error: 60 (Operation timed out)]
svenl has joined #ocaml
munga has quit ["Ex-Chat"]
rwmjones is now known as rwmjones-lunch
BiDOrD has quit [Read error: 104 (Connection reset by peer)]
shr3kst3r has joined #ocaml
kaustuv has quit [Read error: 113 (No route to host)]
kaustuv has joined #ocaml
thrasibule has quit [Connection timed out]
Vital303` has joined #ocaml
Vital303` has left #ocaml []
tmaedaZ is now known as tmaeda0
infoe has quit [Read error: 54 (Connection reset by peer)]
ikaros has joined #ocaml
jimmyb2187 has left #ocaml []
jimmyb2187 has joined #ocaml
rwmjones-lunch is now known as rwmjones
Modius has quit [Read error: 110 (Connection timed out)]
Vecklock has joined #ocaml
david has joined #ocaml
david is now known as Guest53782
Snark_ has joined #ocaml
infoe has joined #ocaml
th5 has joined #ocaml
reid97 has joined #ocaml
BiDOrD has joined #ocaml
Submarine has quit ["Leaving"]
albacker has joined #ocaml
<gildor> rwmjones: do you see the difference with ocaml-gettext 0.3.2 ?
ygrek_ has quit [Remote closed the connection]
<rwmjones> gildor, I built it for fedora today but tbh I didn't really try it out except the tests ... we'll get round to compiling something which needs it soon enough though
<gildor> ok, you'll see that I have made the format string more type checked than before
Guest53782 is now known as Yoric
<Yoric> hi
<Camarade_Tux> hi Yoric :)
seanmcl has quit []
<thelema> hi Yoric. Is it good?
mishok13 has quit [Read error: 110 (Connection timed out)]
<Yoric> Fine, thanks.
<Yoric> Doing some deep compiler work :)
<Yoric> (well, deep into the compiler, not deep into anything else)
<thelema> excellent.
<Yoric> What about you, how are you?
<thelema> It's a better world with more people understanding ocaml's internals.
<thelema> I'm well. I'm finishing up my NSF Fellowship application.
<Camarade_Tux> Yoric: btw, do you have optic fiber at home?
Guest85063 is now known as ezra
ezra is now known as Guest64118
Guest64118 is now known as release
release has quit ["leaving"]
<Yoric> Camarade_Tux, not that I know of.
<Yoric> I believe that my parents do.
<Yoric> thelema, good luck
<thelema> thank you.
<Camarade_Tux> Yoric: ok, I don't have to hate you then ;p
* Camarade_Tux recently tried to get optic fiber but his building wasn't set up for that
<Yoric> :/
<Yoric> thelema, what kind of application is that, exactly?
<kaustuv> Camarade_Tux: Pray that Numéricable doesn't have a monopoly on fibre where you live...
<thelema> 3 years of very good funding for my PhD
<Camarade_Tux> kaustuv: it doesn't, it's just that I just moved in (I'm alone) and I'm never going to get it installed (I'm not going to bother with the "syndic")
<Yoric> thelema, sounds good
<thelema> Yoric: of course it'd be good to get, but it's rediculously competitive.
ikaros_ has joined #ocaml
_unK has joined #ocaml
Vital303 has quit [Read error: 113 (No route to host)]
<infoe> Camarade_Tux: fios?
<Camarade_Tux> infoe: fios? what do you man?
mattiase has joined #ocaml
kaustuv has quit [Read error: 113 (No route to host)]
<orbitz> Fiberoptic Operationg System
<infoe> :/
<infoe> nevermind, youre in france
<Camarade_Tux> I was referring to optic fiber at home 100MB/20MB for 20 euros per month
<infoe> yes, fios is a verizon product
<infoe> which is us territories
<infoe> it is 50MB/20MB tho
<mrvn> and what traffic limit do you get?
<Camarade_Tux> unmetered :)
<mrvn> and if you use the bandwidth how long till they kick you anyway?
<Camarade_Tux> never heard of anything like that here
<mrvn> or shape your P2P into the ground :)
_zack has quit ["Leaving."]
<mrvn> WHat does the % mean in external foo ... = "%foo_stub"?
<Camarade_Tux> they'd like to but they don't
<mfp> mrvn: just posted to the ML about that --- it's a compiler primitive
<mfp> mrvn: those primitive are hardcoded in C-- in the compiler, so it can generate the code directly instead of using a function call
ikaros has quit ["Leave the magic to Houdini"]
<mrvn> mfp: where? I tried to rgrep for the name but that didn't find anything.
<mfp> asmcomp/cmmgen.ml
<mfp> see for instance around line 914, Pbigarrayset
<mrvn> thx.
<mfp> if you find a way to inject C-- expressions into external declarations, you could extend the set of primitives, at least on a per-compilation-unit basis
<mrvn> mfp: Would be ncie to add some primitives for type conversion.
<mrvn> and endian conversion.
<mfp> the primitives are listed in translcore.ml
<mfp> +set of
<mrvn> A syntax to have polymorphic and specialized versions of a function would be nice I think.
<mfp> yes, monomorphization would be very helpful at times
<mattiase> mrvn: Do you mean on the primitive level or in ocaml?
seanmcl has joined #ocaml
<mrvn> mattiase: in ocaml.
<mrvn> e.g. a ('a, 'b) Hashtbl.t and (int, 'b) Hashtbl.t
<mattiase> mrvn: Yes yes, I know. It's quite a taller order
<mrvn> and then what to do if you have (int, 'a) t and ('a, int) t and the user uses (int, int) t
<mattiase> mrvn: this has been explored so often in other contexts, but isn't a generally solved problem
<mrvn> Here is something else to think about. Say you have a double-linked list type. In C code I often have struct Foo { DList primary, secondary, other; int data; }
<mattiase> mrvn: There should be some mechanism on the primitive level - I haven't verified exactly how it's done - but it's probably fairly ad-hoc, to monomorphise comparisons etc
<mrvn> How do I do that in ocaml so I can iterate/map/fold over the primary, seconday or other list?
<mattiase> mrvn: but do you actually want that? It's a low-level C hack to include the membership of objects in themselves
<mattiase> mrvn: but it shouldn't be hard to do that in ocaml, actually
<mrvn> how else do I get from an object to any of the three lists?
<mattiase> mrvn: first define 'a dlist = 'a dlist ref * 'a dlist ref * 'a (say)
<mattiase> mrvn: and then it would be clear to fold over such a dlist
<mattiase> mrvn: You need bidirectional references here: from Foo to each of its three dlist nodes, and from each dlist node to its corresponding Foo
<mattiase> mrvn: (And here it would be better to make 'a dlist into a record with mutable prev/next members)
<mrvn> so DList is { prev, next, 'a } and 'a has 3 'a DList.
ttamttam has quit ["Leaving."]
<mrvn> dlist must be mutable obviously. Otherwise you could only have static lists.
<mattiase> mrvn: Yes, prev and next must be mutable fields, but not the 'a part
<mrvn> The nice thing of the C hack is that it has a low memory footprint.
<mrvn> Time to catch a train and think about this some more.
<mattiase> mrvn: Well, allocating an object directly inside another is nice. Sometimes. It goes both ways.
Yoric has quit [Remote closed the connection]
iZZy_ has joined #ocaml
tmaeda0 is now known as tmaedaZ
tmaedaZ is now known as tmaeda0
iZZy_ has quit [Client Quit]
ikaros has joined #ocaml
ikaros_ has quit [Read error: 110 (Connection timed out)]
tmaeda0 is now known as tmaedaZ
mfp has quit [Read error: 104 (Connection reset by peer)]
tmaedaZ is now known as tmaeda0
mfp has joined #ocaml
tmaeda0 is now known as tmaedaZ
kaustuv has joined #ocaml
thelema has quit ["ubuntu upgrade"]
ztfw has joined #ocaml
ygrek_ has joined #ocaml
thelema has joined #ocaml
ccasin has joined #ocaml
ttamttam has joined #ocaml
<mrvn> but even if I put the DList inside the 'a it will still just be a pointer to a boxed DList record. So not really inside.
<thelema> mrvn: correct, that's the ocaml value model.
<mrvn> again a towsided sword. :)
<ygrek_> flux, extlib doesn't use str
jonafan has quit [Read error: 110 (Connection timed out)]
Guest28077 is now known as fremo
Vital303 has joined #ocaml
Vital303 has quit [Remote closed the connection]
seanmcl has quit []
duryodhan has quit []
ccasin has quit ["Leaving"]
th5 has quit []
dfjoerg has joined #ocaml
<dfjoerg> I have some strange issues with ocamlfind
<dfjoerg> on NetBSD/amd64, it seems like stripping the debug data from the binary breaks it
<dfjoerg> does that ring *any* bell
<Camarade_Tux> stripping debug data or just stripping? if you strip some bytecode ocaml binaries, you can break them
<dfjoerg> strip -g
<Camarade_Tux> it's the binaries which "embed" the interpreter
<dfjoerg> on the ELF binary
<dfjoerg> I can't think of a good reason why it would depend on the debug symbols to be present
<dfjoerg> ieek
<dfjoerg> grmbl
<Camarade_Tux> I don't know to which extent you can run strip but if you have a bytecode program compiled with -custom, better avoid it
<Camarade_Tux> can you check it's actually bytecode?
<flux> ygrek_, good to know for sure. and also it's good that it doesn't :)
<dfjoerg> it obviously strips off content
<dfjoerg> .oO(why not put it into a normal ELF section, *sigh*)
<Camarade_Tux> ocaml is almost as old as C and it might be because of other platforms (windows? a.out?)
<flux> I suppose it could still be changed for supported platforms?
ulfdoz has joined #ocaml
ikaros_ has joined #ocaml
<Camarade_Tux> what I've noticed with ocaml is platform-specific stuff are avoided
<Camarade_Tux> it could be done, but I doubt it will be
<dfjoerg> well, it would allow less hackish behavior
<mrvn> Camarade_Tux: I want it in core libraries
<dfjoerg> similar approaches work for windows, at least
<dfjoerg> not sure about a.out from memory, but a.out is dead
<hcarty> dfjoerg: The less hackish behavior is probably to ship the bytecode and runtime (ocamlrun) separately.
<mrvn> hcarty: that is what debian does.
<hcarty> Native code binaries can be stripped without ill effects.
<dfjoerg> hcarty: I mean the correct approach would be to build a binary that includes the bytecode as loadable section
<Camarade_Tux> well, embedding the interpreter is always a bit weird imho, no matter the language
<mrvn> dfjoerg: bah. stupid duplication of the runtime
<hcarty> mrvn: That makese sense. The Debian OCaml packaging scheme seems to be very well thought out in general.
<dfjoerg> with dynamic linkage it wouldn't be too much, but I am open for better approaches :)
<mrvn> hcarty: if you support 12 archs you have to put some thought into it
<flux> mrvn, it's not duplication, if you don't have other ocaml binaries around :)
<mrvn> flux: we want only ocaml binaries around. World domination.
<dfjoerg> is there a good signature to match binaries with embedded ocaml interpreter?
<hcarty> dfjoerg: You could check if the first line in the file is a #! line
<dfjoerg> it isn't
<dfjoerg> it's an ELF binary
<dfjoerg> otherwise strip wouldn't care :)
<mrvn> #! is the non-custom way I believe
<hcarty> I think that binaries without the interpreter embedded start with a #! ... ocamlrun line
<mrvn> custom: 00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
<mrvn> otherwise: 00000000 23 21 2f 75 73 72 2f 62 69 6e 2f 6f 63 61 6d 6c |#!/usr/bin/ocaml|
<mrvn> 00000010 72 75 6e 0a 54 00 00 00 df 03 00 00 29 00 00 00 |run.T...ß...)...|
<Camarade_Tux> file does it well :)
<dfjoerg> heck, a signature for file(1) would be optimal :)
<mrvn> for that the ocaml linker script would need to embed a signature early in the elf at a fixed offset.
<Camarade_Tux> actually I'm wondering if it doesn't only work in one case and fail in the other
<flux> gildor, is EFD_NONBLOCK something that more recent kernels/libaio have? because I can't build libaio-ocaml due to that missing macro
<mrvn> Camarade_Tux: -custom gives: test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
<mrvn> flux: /usr/include/sys/eventfd.h: EFD_NONBLOCK = 04000
<mrvn> /usr/include/sys/eventfd.h:#define EFD_NONBLOCK EFD_NONBLOCK
<Camarade_Tux> mrvn: maybe it doesn't even have a check for non -custom bytecode programs but only sees the #!*/ocamlrun line
<flux> mrvn, no such line in my eventfd.h..
<mrvn> Camarade_Tux: surely
<flux> mrvn, it originates from libc6 2.8~20080505-0ubuntu9
<mrvn> flux: you need newer linux-kernel-headers I guess.
<mrvn> flux: add #ifndef EFD_NONBLOCK #define EFD_NONBLOCK 0400 #endif
<Camarade_Tux> afaict, EFD_NONBLOCK was added on Date: Wed Jul 23 21:29:38 2008 -0700
<flux> mrvn, ok, linux-header-2.6.27-7-generic ha sit
<mrvn> Camarade_Tux: wow, that was specific.
<flux> I wonder what would be the most decent course of approach
<flux> maybe I'll upgrade to next ubuntu.. 9.04 :-)
<mrvn> flux: that surely doesn't hurt. :)
<Camarade_Tux> flux: 2.6.27-rc1 is from Mon Jul 28
<Camarade_Tux> but this doesn't take branches into account
<mrvn> flux: I'm trying to write a new Buffer module that uses the Bigarray code to access the buffer (compiler builtins) but allows reading any datatype if the alignment fits.
<thelema> sounds like fun
<flux> camarade_tux, yeah, I have an actual relase of that installed, but my libc6-dev is older
<flux> I suppose I could just use kernel headers
<flux> but apparently that's not how things should be done
<mrvn> flux: I would just add the define to the stubs file.
<Camarade_Tux> you better keep kernel-headers and glibc in sync :)
<Camarade_Tux> you *really* better :P
<hcarty> mrvn: I have a "Bigarray.Genarray.cast" function if you're interested.
<flux> no, my distribution should do that :)
<hcarty> mrvn: IIRC it makes a copy of the bigarray though, so it's likely not what you have in mind.
<mrvn> hcarty: that changes a int array to int64 array and the like?
<hcarty> mrvn: Yes
<Camarade_Tux> flux:
<Camarade_Tux> here, I have said nothing against ubuntu :)
<hcarty> mrvn: It should be easy enough to share the data and avoid the copy
<mrvn> Not what I need at all. I want A.get_int8 a 0; a.get_uint8 a 1; a.get_uint16 a 2; a.get_int a 4; a.get_int64 a 8
* Camarade_Tux doesn't use distributions with dependencies but has been hit by bad dependencies several times
<hcarty> Ah, I see
<mrvn> get_int is tricky though. Should that read 32bit or 64bit?
<hcarty> mrvn: Native int?
<mrvn> hcarty: that is boxed.
<mrvn> Whole lot of more problems.
<hcarty> mrvn: Then 31 vs 63 bit OCaml int?
<mrvn> hcarty: yep.
<mrvn> I can provide a get_int31. But how do I provide a get_int63?
<hcarty> mrvn: Native int :-) As in, whatever is native to the system's arch (31 or 63).
<mrvn> and a get_int has to check the buffer size and alignment against whatever the size of int is currently.
dfjoerg has left #ocaml []
<mrvn> Does ocaml have a log(Pervasives.max_int)?
<mrvn> a sizeof(int)
<hcarty> mrvn: Sys.word_size or something like that I think.
<hcarty> Yes, that's it.
<mrvn> thx. didn
<mrvn> 't think to look in Sys
ikaros_ has quit ["Leave the magic to Houdini"]
BigJ2 has joined #ocaml
<mrvn> Or does anyone have an idea how I get external get: ('a, 'b, 'c) t -> int -> 'a = "%caml_ba_ref_1" to emit code for a specific 'b without the first argument having that type?
jonafan has joined #ocaml
* mrvn misses Array1.to_string : (int, int8_unsigned_elt, c_layout) Array1.t -> int -> int -> string but you can't write that in ocaml.
<mrvn> I'm stuck at get_int31. Bigarray has no access function for 31bit integers.
<thelema> mrvn: I thought you weren't going to deal with bits, but stay at the byte level?
<thelema> just read 32-bits and drop one bit
<mrvn> thelema: I want to read 4 bytes but use an unboxed int and it needs to run on 32bit and 64bit cpu.
<thelema> does it need to run the same on either?
<mrvn> It needs to use 4 bytes on both.
<thelema> Int32.to_int
<mrvn> On 32bit cpus I can use a (int, int, c_layout) Array1.t. But on 64bit I need (int32, int32, c_layout) Array1.t and Int32.to_int it seems.
BigJ2 has quit [Read error: 110 (Connection timed out)]
<mrvn> The later results in
<mrvn> 404bb4: 48 8b 05 e5 b1 21 00 mov 0x21b1e5(%rip),%rax # 61fda0 <_DYNAMIC+0x7c0>
<mrvn> 404bbb: e8 50 29 01 00 callq 417510 <caml_c_call>
th5 has joined #ocaml
th5 has quit [Client Quit]
det has joined #ocaml
<mrvn> What is the difference between "a/2" and "a sar 1"?
<thelema> very little
<thelema> I think only the second produces a shift assembly command
<thelema> while the first produces an integer division operation
<mrvn> Yes. But aren't they 100% identical?
<thelema> in terms of the result, yes.
<mrvn> No division. Both use sar but a/2 does extra wierd stuff.
<thelema> the second can be done a lot faster in hardware
<thelema> a/2 is optimized to sar by ocamlopt?
<mrvn> It sees that /2 is a sar but then it conditionally adds 1 for the tag.
<thelema> I didn't realize it would do that kind of optimization
<mrvn> And for that it also needs to free up %rax first.
<thelema> and that's a horrible way to conditionally add the tag
<flux> mrvn, by sar, id you mean lsr?
<flux> in any case, with negative numbers it's very different..
<thelema> flux: no, asr
<mrvn> that would ignore the sign
<flux> ah, ok
<flux> it's still different, though
<flux> not just very different :)
<flux> s/not just/just not/
<thelema> flux: difference?
<mrvn> hmm, -1 >> 1 == -1 but -1 / 2 == 0. right?
<flux> (-5) asr 1 vs (-5) / 2
<flux> so, rounding
<thelema> okay, it's not the same.
<mrvn> I want an unsigned type in ocaml.
<thelema> let compare_uint n1 n2 = let sgn1 = (n1 lsr 24) - (n2 lsr 24) in if sgn1 = 0 then (n1 land 0xffffff) - (n2 land 0xffffff) else sgn1
<flux> I wanto sleep. good night :)
<flux> thelema, that's beautiful
<flux> I shall see dreams about it! ->
<thelema> thank the author of camomile
<mrvn> thelema: and mul and div?
<thelema> mrvn: patch the compiler
<thelema> while you're at it, add overflow checks
<mrvn> thelema: That would only work with different operators.
<mrvn> or actualy better with phantom types.
<mrvn> ['signed 'unsigned] int
<thelema> the compiler isn't bound by the type system
<thelema> and if I were you, I'd do uint
<mrvn> thelema: but then I need to use a different operator for int and uint adition.
<thelema> phantom types seem like a bad choice to me
<thelema> the compiler could work it out.
sramsay has joined #ocaml
ttamttam has quit ["Leaving."]
<hcarty> Phantom types seem like a very interesting approach to unsigned int values in OCaml. Either method (phantom types or a new uint type) could be masked with pa-do.
Yoric[DT] has joined #ocaml
<hcarty> thelema: Why do phantom types seem like a bad choice to you?
<thelema> ugly error messages
<thelema> the longer the types are, the harder it is to read
<mrvn> let m x y = x * y would need to be polymorphic and there is no bit to decide if it is signed or unsigned at runtime.
<mrvn> Might mean you have to specify types in such cases.
<thelema> you'd need to specify for *
<thelema> you'd have (*) : [`signed] int -> [`signed] int -> [`signed] int
<mrvn> Would ruin the "compiler picks the right one" benefit.
<thelema> and (*') : [`unsigned] int -> [`unsigned] int -> [`unsigned] int
<thelema> I see what you're saying - non-phantom types don't union.
<thelema> M would have to be monomorphic of unknown type ('_a)
<hcarty> Wouldn't ( * ) be (I'm not sure of the syntax) ([`unsigned | `signed] as 'a) int -> 'a int -
<hcarty> > 'a int ?
<thelema> hcarty: that's what it'd be for the phantom type case
<thelema> hcarty: but without phantom types, it'd need a monomorphic type for code generation, but it wouldn't know which one until it was used
<hcarty> thelema: Ok, thanks for the clarification. I think I misread/misunderstood an earlier comment.
<thelema> which means it wouldn't be exportable from a module as is
Yoric[DT] has quit ["Ex-Chat"]
<kaustuv> maybe I am old fashioned, but I remember a time when "unsigned int" was called "nat"
<mrvn> hcarty: The problem is that mul is different for signed and unsigned.
ygrek_ has quit [Remote closed the connection]
<mrvn> For it to be exportable in modules the compiler would need to generate the signed and unsigned case in the module and let the using code call the right one. And then you get an exponential explosion of different functions with more and more arguments.
<hcarty> mrvn: Ah, I did not know that. I should read up on various integer representations and the underlying math.
<hcarty> Well, I suppose I did learn that at some point. But it's not something I've thought about in a very long time.
<mrvn> hcarty: It is only through the clever encoding that add/sub is the same. anything else differs.
<mrvn> There is actualy verry little you can do with phantom typed ints that won't fix it to one or the other. So maybe int and uint types with seperate operators isn't a bad idea.
<mrvn> can't even do if x < 10 then
<mrvn> n8
schme has quit [Read error: 54 (Connection reset by peer)]
schme has joined #ocaml
ulfdoz has quit [Read error: 110 (Connection timed out)]
c0m has joined #ocaml
Snark_ has quit ["Ex-Chat"]
jimmyb2187 has left #ocaml []
kaustuv has left #ocaml []
julm has quit [Remote closed the connection]
julm has joined #ocaml
Alpounet has joined #ocaml
chupish has joined #ocaml
valross has joined #ocaml
Yoric[DT] has joined #ocaml
chupish has quit []
albacker has quit ["Leaving"]
ofaurax has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
ikaros has quit ["Leave the magic to Houdini"]
ccasin has joined #ocaml
thrasibule has joined #ocaml
onigiri has joined #ocaml
Vecklock has quit []
valross has quit ["Ex-Chat"]
valross has joined #ocaml
palomer has joined #ocaml
sramsay has quit [Remote closed the connection]