<jpdeplaix>
whitequark: ok I've found a fix but it's still weird :/ It work if I use Extern_weak as linkage method on the two functions declaration
<jpdeplaix>
mmh I see
<jpdeplaix>
it doesn't work in fact :/
<jpdeplaix>
It's just set to null…
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
reem has quit [Remote host closed the connection]
AlexRussia has joined #ocaml
reem has joined #ocaml
AlexRussia has quit [Excess Flood]
<jpdeplaix>
ok, understood. I just forgot to use the global context instead of using and new one every time. I forgot to push the fix last time
AlexRussia has joined #ocaml
antkong_ has joined #ocaml
ptc has joined #ocaml
Jimbo_ has joined #ocaml
ptc is now known as Guest3798
<Jimbo_>
Hi everyone, I'm looking at the bytestring binary parsing package and am wondering how to handle optional fields. Eg, I have a flag that says if a field is present or not.
travisbrady has joined #ocaml
AlexRussia has quit [Ping timeout: 252 seconds]
Algebr has quit [Remote host closed the connection]
Guest3798 has quit [Ping timeout: 246 seconds]
ptc_ has joined #ocaml
q66_ has joined #ocaml
q66 has quit [Quit: Leaving]
q66_ is now known as q66
travisbrady has quit [Quit: travisbrady]
darkf has joined #ocaml
bytbox has joined #ocaml
<tokenrove>
Jimbo_: i match on the flags to handle different optional layouts. or sometimes, stuff the rest into a bitstring (like {rest: -1:bitstring}) and parse it separately based on the flags.
swgillespie has joined #ocaml
<tokenrove>
oh, sorry, i misread what you said; i am thinking of "bitstring", which provides erlang-style bitstring matching, not "bytestring", unless that's what you meant.
<Jimbo_>
Yeah, I'm sorry, I mean bitstring
<Jimbo_>
thanks for the help.
<tokenrove>
no problem. i think that's a great syntax extension. it's been a while since i've used it, though.
associative-pyon has quit [Ping timeout: 245 seconds]
travisbrady has joined #ocaml
antkong_ has quit [Quit: antkong_]
yaewa has joined #ocaml
moei has quit [Ping timeout: 245 seconds]
AlexRussia has joined #ocaml
reem has quit [Remote host closed the connection]
antkong_ has joined #ocaml
AlexRussia has quit [Ping timeout: 265 seconds]
JuggleTux has joined #ocaml
ptc has joined #ocaml
ptc is now known as Guest6845
AlexRussia has joined #ocaml
symmetric-pyon has joined #ocaml
AlexRussia has quit [Ping timeout: 264 seconds]
AlexRussia has joined #ocaml
reem has joined #ocaml
huza has quit [Ping timeout: 250 seconds]
AlexRussia has quit [Ping timeout: 250 seconds]
jao has quit [Ping timeout: 244 seconds]
jabesed has joined #ocaml
symmetric-pyon is now known as geometric-pyon
manud has quit [Ping timeout: 265 seconds]
MrScout_ has quit [Ping timeout: 252 seconds]
nullcat_ has joined #ocaml
<nullcat_>
I am talking with a software engineering PhD in my lab. He is taking PL class and learnt OCaml. He complains to me about debugging in OCaml. From my impression, people here rely more on complier than on debugger. How's the experience of runtime debugging in OCaml? how do you do that effectively? thanks
reem has quit [Remote host closed the connection]
nullcat_ has quit [Read error: Connection reset by peer]
nullcat has joined #ocaml
reem has joined #ocaml
JuggleTux has quit [Remote host closed the connection]
reem has quit [Remote host closed the connection]
<dmbaturin>
nullcat: In functional languages I usually try to prove my code correct if it doesn't work. If I find a contradiction, I know why it was wrong. :)
reem has joined #ocaml
<dmbaturin>
For bugs in code that mutates something a debugger is more useful though, here it's a weak poin indeed.
<nullcat>
i see
reem has quit [Remote host closed the connection]
<dmbaturin>
Post mortem core dump analysis is the case when debugger is indespensible, but making ocaml programs segfault is not that easy. :)
travisbrady has quit [Quit: travisbrady]
nullcat has quit [Ping timeout: 252 seconds]
ggole has joined #ocaml
nullcat has joined #ocaml
reem has joined #ocaml
<dmbaturin>
nullcat: What kind of bugs did you talk about, by the way?
reem has quit [Remote host closed the connection]
<nullcat>
runtime bug definitely, which i think you can just start reasoning and fix it. However, he is a long-time Java developer. He needs IDE and debugger
<nullcat>
i mean simple function, immutable value... in introductory PL class, the functions you need to implement is relatively simple
<dystan>
...and banging my head against trying to find out how to do some of the simplest-seeming things
vpm has quit [Remote host closed the connection]
huza has quit [Client Quit]
<ggole>
Feel free to ask
<dystan>
I like working quickly, so I write ocaml in files beginning with a shebang line (#!...) but haven't succeeded in learning how to make opam-installed libraries visible to the scripts
<ggole>
Oh, I've never done that...
<dystan>
standard libraries are found just fine, and lots of code I've written works just fine
<ggole>
Usually you would use ocamlfind or a build system to take care of locating the library for you
<dystan>
I've got many decades of experience in many languages, and some rusty experience with ocaml, but haven't discovered where to look up how module library access works
<dystan>
my shebang line just runs ocaml on the script in the file. It works great for trying stuff and working fast, but...
<dystan>
I've tried using #directory and #load directives, but I've just been guessing what to tell them, and nothing has worked
<ggole>
Those are for loading files directly, they aren't really appropriate for libraries
<ggole>
Did you try #require?
<dystan>
Dunno where to look for definitive explanation about how all that works.
reem has quit [Remote host closed the connection]
<dystan>
I haven't tried #require but will...
reem has joined #ocaml
<dystan>
#require doesn't seem to be a directive...
<ggole>
Ah, you don't have all that machinery set up yet
<dystan>
Nor is require something that ocaml recognizes...
<ggole>
Essentially #use "topfind" and then #require should work
<ggole>
Usually you place this into .ocamlinit so you don't have to do it each time
<dystan>
It says it can't find file "topfind"
<ggole>
O_o
<ggole>
Oh, I suppose you might be missing ocamlfind
<ggole>
opam info ocamlfind should tell you whether you have that
<ggole>
If not, install it
MercurialAlchemi has joined #ocaml
<ggole>
(It's annoying, I know.)
<dystan>
locate topfind at the shell sees lots of files with topfind in their names.
darkf_ is now known as darkf
<dystan>
$ opam list ocamlfind # Available packages for 4.02.1: ocamlfind 1.5.5 A library manager for OCaml
<ggole>
They could be installed in other versions of ocaml
<ggole>
If you did an opam switch recently, you could just be missing it
<dystan>
4.02.1 is what I'm using -- exclusively. It's the only one installed, other than system, which I'm not using
<whitequark>
did you do eval `opam config env` ?
<dystan>
at the shell?
<ggole>
Yes.
<ggole>
(And if you are running a toplevel from within emacs, and that emacs is not started from the shell, please say so.)
<dystan>
That didn't help, but I think it happens by default, 'cause everything else I've tried seems to work OK
<dystan>
Not running from emacs
<dystan>
I'd sure like to find documentation that pretty thoroughly describes how things are configured and how lookups work, etc....
<ggole>
I still haven't seen whether you've installed ocamlfind
<ggole>
Did you do opam info ocamlfind? (*Not* opam list.)
<dystan>
yes, and got a description just fine
<ggole>
Does it have entries under "installed-version"?
<dystan>
I thought the opam list ocamlfind told me that it was installed
<ggole>
No, opam list will show any available package
<dystan>
installed-version: 1.5.5 [system 4.02.1]
<ggole>
That seems ok... hmm
<dystan>
my opam list doesn't show enough packages to be "any available ...". It looks to me as if it shows the list of things I know I've successfully installed...
<ggole>
If you just type opam list it will give you a list of installed packages (note the preamble before the list)
<ggole>
If you type opam list package you will see any matching available packages
<ggole>
By local I mean in the directory in which you are running the ocaml script
<dystan>
that's what I quoted
<dystan>
nope
<ggole>
/o\
<ggole>
I dunno.
<dystan>
it's a 16 line script
<dystan>
I'm trying to execute from p 296 of "Real World OCaml" where it reads a JSON file using Yojson
<ggole>
Hmm... does running the plain toplevel work?
<ggole>
eg, $ ocaml and then #use "topfind";;
<dystan>
but I've tried to open Yojson, Unix, and other opam-installed packages, some of which I think I remember compiling separately just fine, but where I tell the compile to link the module files
<dystan>
if I say "open Yojson;;" at the ocaml prompt (toplevel?) it gives the same message: "Error: Unbound module Yojson"
<dystan>
Seems like I should be able to find documentation that just covers all this stuff and how it works so I can explore it intentionally...
<ggole>
You need to #require it first
<dystan>
Any suggestions for that?
<dystan>
# #require Yojson;; gives me: Error: Unbound value require
<ggole>
Yes, that's the problem :(
<ggole>
(require takes a string, by the way, but that's not really the issue at hand.)
<dystan>
#use "topfind";; and then #require "Yojson";; gives me No such package: Yojson
<ggole>
Lowercase
<dystan>
the #use "topfind" succeeded at toplevel
<ggole>
And for some reason it seems topfind is working now. :|
<ggole>
Maybe your script is not getting the right environment or something
<dystan>
amazing! I think putting yojson in lowercase did the trick, after getting topfind.
<ggole>
You can verify with #show Yojson
<ggole>
It should print the interface of the module if it is there
<dystan>
now "open Yojson" doesn't get an error. I think your advice has been successful. Thanks!
<ggole>
Phew.
<dystan>
Cool Beans! This is nearly my first time on any form of IRC (in a career of more than 50 years) It's been on my list of necessary things forever...
<dystan>
Now I've gotta learn screen...
<dystan>
I know a guy who hooks IRC to text-to-voice synthesizer and runs it on earphones all day while he works on other things...
<dystan>
Is there a full name and email address to go with <ggole>? or can I just look it up here or something?
<dystan>
Thanks for the help. Looks like complete success.
<whitequark>
"/whois ggole", but many elect to not divulge such details
<dystan>
OK. Thanks. I'll learn...
<dystan>
Got it. Thanks again.
<ggole>
No worries.
<dystan>
I'll lookup how to set my /whois ID... it doesn't look very informative now.
<dystan>
I'll sign off now, and go be productive with my new-found treasure
<dmbaturin>
dystan: Web clients are quite inferior to proper clients such as hexchat.
<dmbaturin>
Or irssi or weechat if you prefer curses UIs.
seangrove has joined #ocaml
<dystan>
Yeah, I gotta get hooked up.
ghostpl_ has joined #ocaml
<dmbaturin>
There's SSL, SASL auth, and some other things web clients rarely or never implement.
<dmbaturin>
Also, it's a good idea to register your nickname.
<dystan>
Yes. I've just been lazy on that, so far. Thanks for the advice.
<dmbaturin>
I know a blind guy who uses text to speech to use IRC and SSH to servers.
<dystan>
Makes sense to me.
<dystan>
bye for now...
dystan has quit [Quit: Page closed]
reem has quit [Remote host closed the connection]
Submarine has joined #ocaml
malc_ has joined #ocaml
reem has joined #ocaml
ghostpl_ has quit [Remote host closed the connection]
Submarine has quit [Remote host closed the connection]
moei has quit [Read error: Connection reset by peer]
moei has joined #ocaml
lostman has joined #ocaml
tane has joined #ocaml
dmiles_afk has quit [Remote host closed the connection]
dmiles_afk has joined #ocaml
dmiles_afk has quit [Remote host closed the connection]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
nullcat has joined #ocaml
madroach has joined #ocaml
thomasga has joined #ocaml
psy_ has quit [Ping timeout: 246 seconds]
thomasga1 has joined #ocaml
thomasga has quit [Ping timeout: 256 seconds]
myyst has joined #ocaml
ia0 has quit [Quit: leaving]
octachron has joined #ocaml
ia0 has joined #ocaml
myst has quit [Ping timeout: 250 seconds]
MercurialAlchemi has quit [Remote host closed the connection]
malc_ has quit [Ping timeout: 246 seconds]
MercurialAlchemi has joined #ocaml
malc_ has joined #ocaml
huza has joined #ocaml
reem has quit [Remote host closed the connection]
myyst is now known as myst
<tane>
morning
<tane>
is there any tool to automatically generate ctypes ml files from c-header files?
<whitequark>
no
<tane>
ok, thanks
segmond has quit [Ping timeout: 252 seconds]
freling has joined #ocaml
Haudegen has quit [Ping timeout: 264 seconds]
<mrvn>
I think there is a ppx that can so some limited inlineing of C files.
<whitequark>
no
Kakadu has joined #ocaml
huza has quit [Quit: WeeChat 0.3.8]
Simn has joined #ocaml
Haudegen has joined #ocaml
segmond has joined #ocaml
hilquias has joined #ocaml
thomasga1 has quit [Quit: Leaving.]
zpe has joined #ocaml
thomasga has joined #ocaml
pii4 has quit [Quit: [-.-]...]
thomasga has quit [Client Quit]
pii4 has joined #ocaml
robindunbarr has quit [Quit: robindunbarr]
reem has joined #ocaml
captain_furious has joined #ocaml
robindunbarr has joined #ocaml
robindunbarr has quit [Client Quit]
reem has quit [Remote host closed the connection]
reem has joined #ocaml
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<whitequark>
for example ~/opam-overlay/compilers/4.02.1+clang
<whitequark>
then alter the configure line to this: ["./configure" "-prefix" prefix "-with-debug-runtime" "-cc" "clang" "-aspp" "clang -c"]
segmond has joined #ocaml
<_gio>
thanks whitequark
yomimono has joined #ocaml
thomasga has quit [Quit: Leaving.]
<_gio>
ah ah, whitequark you could add something like that to the repo? noo?!
<_gio>
:-)
_andre has joined #ocaml
<_gio>
4.02.1+clang and 4.03.0+clang could be really useful
<whitequark>
what for?
govg has quit [Ping timeout: 244 seconds]
<_gio>
really, they aren't so useful
<_gio>
what I want is to have a way to tell to opam to use a specific compiler
<Leonidas>
isn't it possible to just set $CC?
robindunbarr has quit [Quit: robindunbarr]
<_gio>
the shortest way is to create a symbolic link gcc->clang (adding the relative dir to the head of the PATH variable)
<whitequark>
ew.
Thooms has joined #ocaml
paradoja has joined #ocaml
dsheets_ has joined #ocaml
<_gio>
ok, thanks guys
<_gio>
it's time to go, there's a wonderful Sun outside
<_gio>
;) bye
_gio has quit []
lostman has quit [Quit: Connection closed for inactivity]
segmond has quit [Ping timeout: 245 seconds]
ebzzry has quit [Remote host closed the connection]
Haudegen has quit [Ping timeout: 246 seconds]
antkong_ has quit [Quit: antkong_]
mengu has joined #ocaml
antkong_ has joined #ocaml
Haudegen has joined #ocaml
thomasga has joined #ocaml
lordkryss has joined #ocaml
ghostpl_ has joined #ocaml
ghostpl_ has quit [Remote host closed the connection]
ghostpl_ has joined #ocaml
ghostpl_ has quit [Remote host closed the connection]
ghostpl_ has joined #ocaml
segmond has joined #ocaml
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
segmond has quit [Ping timeout: 256 seconds]
thomasga has quit [Quit: Leaving.]
toolslive has joined #ocaml
Thooms has quit [Ping timeout: 240 seconds]
antkong_ has quit [Quit: antkong_]
Thooms has joined #ocaml
thomasga has joined #ocaml
segmond has joined #ocaml
malc_ has quit [Quit: leaving]
ghostpl_ has quit [Remote host closed the connection]
ghostpl_ has joined #ocaml
jao has quit [Ping timeout: 246 seconds]
thomasga has quit [Quit: Leaving.]
ghostpl_ has quit [Remote host closed the connection]
<companion_cube>
hannes: for your xmpp client, do you plan to use lambda-term?
ghostpl_ has joined #ocaml
<companion_cube>
hmm, never mind
vanila has joined #ocaml
aubergines has joined #ocaml
segmond has quit [Ping timeout: 240 seconds]
<apache2>
I had some problems with String functions on strings containing 0x00
ebzzry has joined #ocaml
<companion_cube>
do you have an interface to C?
<apache2>
whitequark: how's your distributed file storage thing coming along btw?
<apache2>
re: 0x00: is that a bug, or should I use another type? I was under the impression that with immutable strings, the strings were basically binary safe?
<apache2>
companion_cube: it already uses lambda-term.
<companion_cube>
I think you might have problems if you call some underlying C function
<companion_cube>
because it will stop at \0 rather than the real string length
<apache2>
I'm just using standard String functions, I expected them to be binary safe :P
<mrvn>
does ctypes support bytes now?
ghostpl_ has quit [Ping timeout: 245 seconds]
<apache2>
companion_cube: yeah, same problem in PHP. I hoped OCaml would have a nicer string handling interface than PHP :P
<mrvn>
apache2: ocamls strings have a length. 0 bytes don't disrupt anything.
<apache2>
I mean -- some of the functions don't mind 0x00, and the strings themselves are fine. it's just some of the functions in String that don't seem to be coping
<mrvn>
apache2: you just can't pass them e.g. printf()
<mrvn>
apache2: do you have an example where \000 breaks a String function?
<companion_cube>
well, it works for me, at least when I write a string with \x00 in the middle to some file
<mrvn>
using write(str, off, len)?
<companion_cube>
using output_string
<mrvn>
that iirc goes back to write too.
<companion_cube>
but it doesn't use strlen, which is a good thing
<mrvn>
No, it uses String.length. much faster.
<companion_cube>
exactly
<apache2>
write() is a system call which takes length, the problem probably lies with libc functions that expect strings to be C-style zstrings
<mrvn>
ctypes should use String.length too. You just have to make sure your C code can cope with 0 bytes.
<apache2>
mrvn: I don't have one now, but I'll investigate. Glad that it's not just me :)
<mrvn>
i.e. if you call strlen(const char *) via ctypes it will fail.
<mrvn>
But that is totaly as expected.
<apache2>
strlen in libc works on zero-terminated strings, you could say that those are a different type than ocaml strings
<mrvn>
apache2: the alternative is tu use a Bigarray
<companion_cube>
well, Ocaml strings are 0-terminated, but they also have a length field
segmond has joined #ocaml
nullcat has joined #ocaml
<apache2>
why have both?
<apache2>
sounds like a type problem if you allow zerobytes inside strings and use the length field in some cases and use the first 0-byte in other cases
<mrvn>
so you can pass the string to C functions
<mrvn>
you don't have to add the 0 byte every time
<apache2>
semanticlly speaking you shouldn't be able to pass a string containing 0-bytes to an underlying c function that terminates on first 0-byte
<mrvn>
consider it a safety measure in case you do pass a string to a C function expecting a 0 byte and the string doesn't have one itself.
<toolslive>
are you sure ocaml strings also have a \x00 at the end ?
<mrvn>
I'm not
<toolslive>
there's some padding....
<apache2>
mrvn: I'd rather have a compile-time complaint that I'm using the wrong type of string than an incomplete string being handled by the c function
<whitequark>
toolslive: they always do
nullcat has quit [Ping timeout: 245 seconds]
<mrvn>
I know they have a length (in words) in the tag word and a length (remaining bits) as last byte.
<toolslive>
but isnt' that just a coincidence of the padding ?
<whitequark>
it's guaranteed by runtime
<apache2>
why not have a string type that's 0-terminated?
<toolslive>
0-terminated strings are a terrible idea
<toolslive>
from a different era
<companion_cube>
as is C
<companion_cube>
but we have to live with it
<mrvn>
Maybe a 7 byte string is "abcdefg\0" and a 6 byte string "abcdef\0\3"?
<apache2>
I concur with toolslive. Also, there should be a functio nfor determining the length of a zero-terminated string.
<mrvn>
As in the length correcting byte is 0 when the string is 1 short of a word
<mrvn>
exactly. So the fact that a string has a 0 byte at the end is a side effect of the padding.
<apache2>
Care should be taken that any C library functions that receive these buffers can also cope with arbitrary bytes within the buffer contents and are not expecting C strings. For instance, the C memcopy or memmove standard library functions can operate on arbitrary data, but strlen or strcpy both require a NULL-terminated buffer, and neither has a mechanism for encoding a NULL value within its contents.
<apache2>
<-- that seems sort of weird
<whitequark>
it IS guaranteed by the runtime, the runtime itself makes use of that feature
<whitequark>
it's not "just" a side effect of padding
<apache2>
Why would you first explain that 0-termination is super handy and nice, then add a disclaimer that you should only pass ocaml strings to functions that take length?
<mrvn>
apache2: ocaml strings are compact byte arrays. Not 0-terminated strings.
<vanila>
the whole thing is a mess.. strncpy may not add a \0
<companion_cube>
strings in C are a nightmare anyway
<apache2>
mrvn: yeah -- in some cases, it seems :P
<mrvn>
apache2: in all cases. But you are allowed to write bad code that asumes there is no 0 in them if you like.
<apache2>
vanila: you'd use memcpy if the string contains 0-bytes anyway :P
<mrvn>
at your own peril
<apache2>
mrvn: yeah. that's sort of a big gotcha. would be nicer to just have a type for that.
<mrvn>
apache2: too hard to prove at compile time.
<toolslive>
C has no strings.
<apache2>
using that logic you could have every single type in ocaml be a compact byte array and just do case-specific parsing
<mrvn>
apache2: let set s x c = s.[x] <- c. Does that add a 0 byte or not?
<apache2>
mrvn: it shouldn't.
<toolslive>
it has char pointers and a char is something that's platform dependent.
<apache2>
mrvn: unless c is '\0'
<mrvn>
apache2: you would need a type char and type char_but_not_0
<toolslive>
a char can even be 16 bits wide (yes, such platforms exist)
<toolslive>
(it's a complete mess)
<apache2>
mrvn: rather that than this transparent, hard-to-debug catch
<mrvn>
And then how do you convert int to char_but_not_0 without rislking a runtime exception NULL
<apache2>
toolslive: on windows they all are
<mrvn>
apache2: simply don't use C string functions, use mem*
<mrvn>
apache2: they are faster anyway.
<whitequark>
apache2: no, that's wchar_t. char is still 8-bit on windows
<apache2>
mrvn: I don't want to use C string functions -- it's not me who's asking for this behavior :P
<whitequark>
char is required to be the minimal addressable unit of the target platform
<mrvn>
windows even has 4 byte longs
<whitequark>
which is an octet on anything where windows runs
<apache2>
whitequark: but all strings are UCS ?
<mrvn>
whitequark: used to half that on early alphas
<apache2>
whitequark: some platforms have adressable bits
<whitequark>
apache2: no? they're wide strings if you use L"foo", regular if you use "foo"
<whitequark>
addressable bits... unaware of
<whitequark>
some DSPs have a 16-bit minimal addressable unit
<whitequark>
and a 16-bit char, correspondingly
<apache2>
either way, I assume ocaml "char" is different from "cpu/c char" ?
<apache2>
so you can always assume that an ocaml char is an octet
<whitequark>
it has range of 0..0xff
<whitequark>
(internally it's an int)
<Drup>
whitequark: high order functor, you are getting fancy. :]
<apache2>
mrvn: re: runtime exception null: don't you think a runtime exception null is better than silently doing something unexpected?
<whitequark>
Drup: for bonus points, it's passed to another higher order functor
mengu has quit [Remote host closed the connection]
<mrvn>
apache2: no. I think it's better to not use broken C functions
<apache2>
mrvn: they're not broken. they just have a different concept of string than ocaml.
<mrvn>
apache2: the concept is broken
<apache2>
the libc functions that expect 0-terminated strings handle 0-terminated strings quite well
<whitequark>
0-terminated strings have no right to exist
<tane>
...
<apache2>
mrvn: yeah, but the ocam lruntime is implemented in C, as is a lot of other things, so we can't rid ourselves of having to know about and deal with issues related to this
<mrvn>
apache2: it's slow, it's error prone, it has braindead things like strncpy() not 0 terminating
<apache2>
what's the difference between strncpy and memcpy?
<whitequark>
it's probably the second worst decision in modern computing after null pointer
<mrvn>
apache2: strncpy() can end early
<apache2>
lol
<apache2>
ok, scratch what I said about libc string handling working well
<mrvn>
apache2: strncpy terminates when it sees a 0 byte. Otherwise it copies n bytes.
ghostpl_ has quit [Remote host closed the connection]
<vanila>
the docs just kind of list the various types and give examples, I need something that explains why the operational semantics is safe when the program is well typed
Haudegen has joined #ocaml
<whitequark>
I don't think there is an explicit document
<whitequark>
also I don't think there is any attempt at formalizing the operational semantics at all
<whitequark>
thus it could well be unsound
<whitequark>
I mean, look at the I-crash I-wrong or I-ICE tags on the bugtracker
<vanila>
oh this is interesting
Haudegen has quit [Read error: Connection reset by peer]
<vanila>
this might have some relevant foundational stuff
<companion_cube>
looks nice (weird font though)
<companion_cube>
Pottier made a lot of work on Mezzo, a language based on Ocaml with linear types
<companion_cube>
(well, permissions)
<vanila>
I think someone told him not ot use comic sans, and this is the payback
<vanila>
yeah mezzo is so cool!
<companion_cube>
:D
<vanila>
I was just reading about that last week
<vanila>
I like seeing these really interesting new languages come up
<companion_cube>
I'm not sure Mezzo will ever be used by more than a few people
ptc has joined #ocaml
ptc is now known as Guest47757
dsheets_ has joined #ocaml
Guest47757 has quit [Ping timeout: 246 seconds]
mort___ has joined #ocaml
ptc_ has joined #ocaml
mengu has joined #ocaml
OnkV has joined #ocaml
OnkV has quit [Read error: Connection reset by peer]
OnkV has joined #ocaml
OnkV has quit [Read error: Connection reset by peer]
vpm has joined #ocaml
darkf has quit [Quit: Leaving]
octachron has joined #ocaml
ptc_ has quit [Ping timeout: 264 seconds]
amirmc has quit [Read error: Connection reset by peer]
amirmc has joined #ocaml
OnkV has joined #ocaml
thomasga has joined #ocaml
Algebr has joined #ocaml
<Algebr>
I'm using ocamldebug on a lambda-term based program and small annoyance is that the commands aren't being printed. They still execute correctly, ie print some_variable, but I don't actually see the commands. Known issue?
OnkV has quit [Ping timeout: 246 seconds]
jabesed has quit [Quit: Konversation terminated!]
amirmc has quit [Ping timeout: 244 seconds]
jabesed has joined #ocaml
<whitequark>
you can't use ocamldebug on anything effectful
<whitequark>
especially you can't use ocamldebug on something that mutates the state of the terminal
<Algebr>
hmm, its basically working, just that annoyance.
<whitequark>
that it works is an illusion
<whitequark>
try to compile let () = print_endline "a"; print_endline "b"; print_endline "c", and step it backwards
<ggole>
Unprinting something would be a neat trick
amirmc has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
<Algebr>
heh.
<whitequark>
well, nothing in principle prevents you from making a terminal that works like that!
travisbrady has joined #ocaml
<mrvn>
all you need is a magic marker
<whitequark>
it's very simple actually
<ggole>
One possibility I've heard of before is to record side effects but not commit them, which would let you time travel fully
<ggole>
But you need an accurate model of the system to make that work
<mrvn>
implement the console in ocaml. problem solved
<whitequark>
simpler :) you just need to put the escape code interpreter /inside/ the ocaml program, and make the terminal display a "view" into the state of that virtual terminal
<ggole>
Probably possible for printers, but not arbitrary I/O
thomasga has quit [Quit: Leaving.]
<whitequark>
hum. it appears that ocamlopt -output-obj basically never worked
<whitequark>
fun.
dsheets_ has quit [Ping timeout: 246 seconds]
<companion_cube>
is rginberg taking vacations?
badkins has joined #ocaml
<mrvn>
Huh? I've used that sucessfully
<mrvn>
whitequark: how does it not work?
<whitequark>
mrvn: doesn't link in C stubs
<whitequark>
from the libraries you use
<mrvn>
it outputs an .o file. You link that with whatever you need.
<whitequark>
it's useless
<whitequark>
I'm not going to hunt down every C stub my code happens to use and link it in manually
<mrvn>
it might be inconvenient but it totaly works
<whitequark>
no, it's broken. it does not implement a useful behavior
<mrvn>
I would let the build system do the hunting.
<whitequark>
and how would the build system know that?
<mrvn>
whitequark: It outputs an object file. not a shared lib.
<mrvn>
whitequark: same way ocaml does, from the meta files
<whitequark>
those do not include the C stubs
<mrvn>
but the cmxo files
<companion_cube>
whitequark: I'm counting on you for the release of containers 0.9 ;)
<whitequark>
mrvn: cmxo files?
<whitequark>
there are no cmxo files
<whitequark>
since autolink was implemented, the C stubs are included in the cma/cmxa file header
<mrvn>
cmxa I mean
<whitequark>
the only thing that can programmatically extract those is ocamlc/opt itself
<whitequark>
ocamlobjinfo does not output the data in machine-readable format
govg has joined #ocaml
<whitequark>
and even if it did, it would be a horrible idea
OnkV has joined #ocaml
<whitequark>
because the build system has /already provided/ all the data to ocamlopt it needs to build a useful artifact instead of some junk you can't link anywhere
<mrvn>
whitequark: I'm not sure how you think this should work. .o files aren't linked against other stuff normaly.
<whitequark>
it already doesn't do it "normally"
<whitequark>
because it builds that .o file with an ld -r command, from a bunch of other .o files
<mrvn>
it does the same thing "gcc -c" does.
<whitequark>
no
<whitequark>
it essentially builds a static library
<whitequark>
except it puts it into a .o because ???
<mrvn>
it builds a simple single .o file.
<mrvn>
You can build a .o out of multiple .o files.
<whitequark>
why are you arguing that a behavior that is not useful is correct?
<mrvn>
What you want sounds a like a shared lib with all the stubs linked in.
<whitequark>
I want a static lib, actually
<whitequark>
it already makes a sort of static library
<mrvn>
whitequark: I'm just saying that it is usefull, it works. I use it to link ocaml against my exokernel to run ocaml baremetal.
<whitequark>
yeah, now add something with C stubs
<mrvn>
I have. e.g. threading
<whitequark>
that doesn't use autolink though
<whitequark>
add, say, sodium
<mrvn>
or my framebuffer
uris77 has joined #ocaml
OnkV has quit [Ping timeout: 244 seconds]
<mrvn>
whitequark: at the end I simply link boot.o kernel.o threading.o framebuffer.o ocaml_obj.o into kernel.elf and then boot that on my Raspberry
<whitequark>
very convenient.
<mrvn>
autolink would be more conventient. BUt I wouldn't call it useless.
<whitequark>
my point is: there is no way to get ocaml to tell you which C stubs would these cma/cmxa require
<whitequark>
and it already knows that when it does -output-obj
<hannes>
companion_cube: no, I just found an issue in our implementation..
<mrvn>
whitequark: output looks like the filename followed by a rfc822 block. Seems perfectly parseable.
<hannes>
nothing too worrying... pinata won't hand out secrets
<companion_cube>
but did you update the piñata code?
<whitequark>
mrvn: are you trolling me or what?
<hannes>
companion_cube: it doesn't hand out secret.. will update at some point..
Haudegen has joined #ocaml
<whitequark>
"perfectly parseable" for some format from an internal utility which is not even specified anywhere?
<whitequark>
perfectly fucking parseable
<companion_cube>
hannes: ok, cool.
<mrvn>
whitequark: do you want to find a solution that works or just bitch?
<whitequark>
I don't call some ad-hoc patch that might or might not break in a next minor release a "solution that works"
<mrvn>
whitequark: then go and implement ocamlopt -output-lib
<whitequark>
what the fuck am I doing right now do you think?
<rks`>
:D
<mrvn>
whitequark: right now? bitching on irc
<whitequark>
apart from wasting time by listening to you defending this clearly broken behavior
<toolslive>
does anyone know the eta for the ocaml multi-runtime (native) ?
<whitequark>
there is no eta
<whitequark>
"it will be done when it is done"
<MercurialAlchemi>
the Duke Nukem Forever ETA
<mrvn>
toolslive: now that you mention it and since the Raspberry Pi has 4 cores ... I'm thinking of running 4 ocamls on that using copy-on-write on the data section to make them independent.
<companion_cube>
the duke nukem forever runtime
* MercurialAlchemi
imagines a camel with sunglasses, a cigar and an RPG
<mrvn>
MercurialAlchemi: sorry, that is trademarked by the Camel ciggarets.
<MercurialAlchemi>
a caml then
<MercurialAlchemi>
:)
<MercurialAlchemi>
"smoke an RPG and die quicker"
Kakadu has quit [Ping timeout: 246 seconds]
govg has quit [Quit: leaving]
govg has joined #ocaml
thomasga has joined #ocaml
<mrvn>
MercurialAlchemi: point it at the ground, are you ready to fly?
<oriba>
I want to use opam to create arch-packages (PKGBUILD). For that I want to use the system-installed ocaml for compilation and want to install into a certain directory from <path-to-sources> into <path-to-package>.
<dmbaturin>
companion_cube: I run a bot with offline messaging and factoids plugins for another channel, I could possibly bring it here unless anyone objects.
<oriba>
Are there easy startinmg-docs, explaining this ?
<companion_cube>
this kind of bots doesn't spam at all, right?
<companion_cube>
it's more about private messages
<dmbaturin>
companion_cube: No, I avoided any spammy features. It sends a PM with that message when the received speaks on the channel again.
<dmbaturin>
* receiver
<companion_cube>
ok, nice
<companion_cube>
I think that if it spams, it won"t bother people of this chan
<companion_cube>
if it doesn't spam*
<dmbaturin>
Sadly, it's not written in ocaml, so it kind of breaks the tradition.
<companion_cube>
oh, well.
<whitequark>
there's _whitelogger already
<whitequark>
written in ruby
<seangrove>
As long as you can eval ocaml code in the channel with some prefix
<whitequark>
no such bot
<Drup>
for some reason, it was decided not to have that.
<dmbaturin>
Eval bots only provoke eval spamming IMHO.
ptc has joined #ocaml
ptc is now known as Guest3237
<companion_cube>
ok, so bots need have a _ prefix so they are not exported :>
<dmbaturin>
Exported?
shinnya has quit [Ping timeout: 240 seconds]
<companion_cube>
bad joke about the convention in utop (and ocamlc?)
<ggole>
Only in utop
<ggole>
(And only printing, I think.)
slash^ has quit [Read error: Connection reset by peer]
slash^ has joined #ocaml
amirmc has quit [Quit: Leaving.]
gargaml has quit [Quit: WeeChat 1.1.1]
thomasga has quit [Quit: Leaving.]
Algebr` has joined #ocaml
<Algebr`>
General question, is there a relationship between the index of a sorted sequence of a BST and the node itself? Like say you're given the index of the sorted sequence, can you use that to arbitrarily get back the node itself?
<Drup>
only if you know what traversal was used to build the sequence
<Algebr`>
say in-order
<Algebr`>
would you then have to do that sort anyway? or can it be done without having to sort.
<Drup>
then yes
<Drup>
oh, huum
<Algebr`>
yea, I don't want to sort it, but I do know that I want the node of index r had I did sort it.
bytbox has joined #ocaml
oriba has quit [Quit: Verlassend]
<ggole>
A perfect BST and the sorted sequence of its nodes have a relationship
<ggole>
I don't think arbitrary BSTs have that property though
jao has joined #ocaml
<Algebr`>
ggole: How can I get the node of a perfect BST if all I have is the index of a sorted sequence?
jao has quit [Changing host]
jao has joined #ocaml
<ggole>
Hmm, you essentially do binary search
<ggole>
Instead of element comparisons you choose the path which leads you towards the target index
<Algebr`>
yea, I get that, but I'm not sure of the relevance of the index in the comparing logic
<ggole>
Well, a pair of indexes into a sorted array are like a node pointer in a tree traversal
<ggole>
When the pair of indexes are trivial (the interval is empty), you're at a leaf
<Algebr`>
What do you mean by pair? Why a pair since I just have one index?
octachron has quit [Quit: Leaving]
<ggole>
You need to know how much array you are looking at
govg has quit [Ping timeout: 250 seconds]
mort___ has quit [Ping timeout: 250 seconds]
<Algebr`>
oh, right, it goes down by half for each iteration
<ggole>
So "searching" for the node corresponding to an arbitrary index would be, hmm
govg has joined #ocaml
<ggole>
I think it would be fairly straightforward, but you'd need the tree cardinality
jwatzman|work has joined #ocaml
<Algebr`>
Where can I see an example of this?
<ggole>
No idea.
ned has joined #ocaml
<ggole>
Let's see, do you know how to construct a perfect bst from a sorted array?
ned is now known as Guest59124
<ggole>
That's a problem related enough that it might point the way
ned- has quit [Ping timeout: 250 seconds]
captain_furious has quit [Ping timeout: 265 seconds]
<Algebr`>
thanks
<ggole>
It's an interesting little corner of CS
<ggole>
The relationship holds for other orderings too, like depth-first
<ggole>
And the classic heap algorithms
mengu has quit []
toolslive has quit [Quit: Leaving]
Guest3237 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
thomasga has joined #ocaml
nlucaroni has joined #ocaml
olauzon has joined #ocaml
Anarchos has joined #ocaml
Haudegen has quit [Ping timeout: 264 seconds]
amirmc has joined #ocaml
vanila has quit [Quit: Leaving]
jabesed has quit [Ping timeout: 250 seconds]
Haudegen has joined #ocaml
axiles has joined #ocaml
Submarine has joined #ocaml
MrScout has joined #ocaml
yomimono has quit [Ping timeout: 250 seconds]
thomasga has quit [Quit: Leaving.]
matason has quit [Ping timeout: 264 seconds]
paradoja has quit [Ping timeout: 265 seconds]
badkins has quit []
ptc has joined #ocaml
ptc is now known as Guest25274
Guest25274 has quit [Client Quit]
ptc_ has joined #ocaml
bytbox has quit [Ping timeout: 252 seconds]
<Algebr`>
How would one go about say writing a GUI app in objective C and the logic in OCaml? Would that be basically like calling ocaml from C code?
<whitequark>
yes
<Anarchos>
Algebr` i did that kind of object but i run ocaml first, and then call C from ocaml... i don't know which is the best way to do it
<whitequark>
there's practically no difference
bytbox has joined #ocaml
<Anarchos>
i prefer to run the monothreaded app first :)
amirmc has quit [Quit: Leaving.]
badkins has joined #ocaml
Anarchos has quit [Quit: reboot to test my ahci layer]
Haudegen has quit [Ping timeout: 245 seconds]
amirmc has joined #ocaml
bytbox has quit [Ping timeout: 264 seconds]
<Algebr`>
Any sharable exampleS?
Haudegen has joined #ocaml
<whitequark>
no good OSS examples, sorry
<Algebr`>
So are people actually able to write iOS apps using ocaml?
<whitequark>
you need osx installation media. it's ... a bit involved
<def`>
(out of curiosity, what kind of app did you used ocaml for on iOS ?)
<whitequark>
it is a disk image, it has a disk image inside, which has another disk image which is bootable
Nahra has joined #ocaml
<whitequark>
i don't remember the exact paths but it took me just a few minutes to figure it out
<whitequark>
other than that it's not different than installing any other os
<whitequark>
at all
<def`>
I have a dump of a recovery partition, I'll look on it.
<whitequark>
i run it headless. pass -daemonize -display vnc=:10
<whitequark>
use vncviewer :10 to poke the chameleon boot, which for some reason doesn't want to boot first entry on timeout
<whitequark>
then i just enabled ssh
<whitequark>
if you take os x out of os x, it becomes actually usable
<def`>
:D
<whitequark>
multi-core compiling is OK, maybe 1.5x slower than host
<whitequark>
it eats some battery, but not too much
<whitequark>
(what kind of app) NDA
MrScout has quit [Ping timeout: 265 seconds]
Algebr` has quit [Remote host closed the connection]
MrScout has joined #ocaml
<def`>
ok
mort___ has joined #ocaml
<ousado>
whitequark: wow, nice
<whitequark>
ousado: what is?
<ousado>
OSXKVM/
WraithM has quit [Quit: leaving]
captain_furious has joined #ocaml
<_obad_>
I have a noob React/Lwt question (again.) I created an event with E.create. this gives me an event and a sender. now I have a function that I want to be called everytime the event is fired. what do I use? map_s? app_s? Also, those return events... do I have to keep them? what's the equivalent of List.iter?
travisbrady has joined #ocaml
ggole has quit []
<whitequark>
app_s I think
ptc_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Kakadu has joined #ocaml
<_obad_>
whitequark: app_s is takes functional events val app_s : ('a -> 'b Lwt.t) event -> 'a event -> 'b event
<Algebr>
bool option is kinda of weird to me. None is kind of like saying Some false
bytbox has joined #ocaml
<Drup>
see it this way
<Drup>
bool option has 3 states, bool has 2
<Drup>
simple as that :p
lordkryss has quit [Quit: Connection closed for inactivity]
<Algebr>
heh, okay, make sense. Drup, do you know if lambda term has a way to raise an event when two widgets overlap?
<Algebr>
or draw over each other
<Drup>
hum, I doubt it
<def`>
[or imagine a user setting preferences in a software, for a boolean setting, it can force it to true, to false, or leave the default (None)].
<Drup>
but if you are doing things like this ... chances are you shouldn't use the widget system
<Drup>
don't do collision detection with widgets :D
<Algebr>
yea, guess I'll just have to do the checking by hand.
<Algebr>
Is ncurses lower level than lambda term?
<Drup>
ncurse is broken, don't use it
freling has quit [Quit: Leaving.]
<Drup>
the one and only use for ncurse it to segfault
<Algebr>
heh, I'm just asking cause lambda term advertises itself as a high level interface to the terminal, but is that trying to say that ncurses is low level? And anyway, good stuff has been written with ncurses...
<Drup>
(and no. lambda-term has both the high and low level apis)
<Drup>
sure, good stuff has been written with COBOL too, the whole banking rely on them :D
<Drup>
(oh wait)
<Drup>
believe me, I tried ncurse before using lambda-term, it's not worth it ;)
vfoley has quit [Ping timeout: 246 seconds]
ontologiae_ has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
<Algebr>
Drup: I'm trying to catch the exception of LTerm_draw.Out_of_bounds but I'm not getting it because I think of something to do with Lwt.
<Drup>
read about error handling with lwt
<Drup>
it's in the doc
MrScout has quit [Remote host closed the connection]
<Algebr>
seems like lwt touches all parts of the language..
<_obad_>
is it legal to call Lwt.cancel on regular tasks?
<whitequark>
on any tasks
<whitequark>
but unless it's waiting on something cancelable like IO or a waiter, nothing will happen
<whitequark>
which is what allows you to avoid a race condition
<_obad_>
whitequark: well I'm getting a strange segfault. I'm implementing a simple read-from-serial with timeout
olauzon has quit [Quit: olauzon]
<whitequark>
actually, no, disregard the part about races
<_obad_>
I create two tasks, one is just Lwt_unix.sleep, the other does the read; I wait for the first one to complete with <?>
<_obad_>
then I cancel both. however I get a segfault :(
<_obad_>
if I remove the cancel... well the timeout kicks in but no segfault
<whitequark>
that really should not happen
<whitequark>
seems like a bug in lwt
<_obad_>
could be a bug somewhere else, I have some C bindings, however it is suspicious
<MooseAndCaml>
sorry the weird pasting there... hello (in a less robo tone)
<_obad_>
what does the compiler say?
<MooseAndCaml>
I updated the gist with the error
<Kakadu>
L1.iter (fnc prv h2) h;
<Kakadu>
fnc doesn't return unit
<MooseAndCaml>
shouldn't changing a mutable field just return unit?
<mrvn>
it does
<Kakadu>
you return x explicitly
<Kakadu>
why do you expect it to return unit?
<Kakadu>
x is a record
<MooseAndCaml>
oh... horror... i see it
travisbrady has joined #ocaml
<MooseAndCaml>
oof... that compiled now. Working with mutable values - especially fields, has my code feeling pretty clumsy. For instance, is the ; required to process mutable values - similar to haskell or does ocaml process each let as it comes?
<whitequark>
x; y is syntactic sugar for let () = x in y
<whitequark>
it has no relation to mutable values per se
<MooseAndCaml>
ok, that makes sense. I'm glad to have that mystery cleared
antkong has joined #ocaml
Kakadu has quit [Remote host closed the connection]
jabesed has quit [Quit: Konversation terminated!]
captain_furious has joined #ocaml
MooseAndCaml has quit [Ping timeout: 246 seconds]
shinnya has joined #ocaml
claudiuc has quit [Ping timeout: 256 seconds]
claudiuc_ has joined #ocaml
Thooms has joined #ocaml
ontologiae_ has quit [Ping timeout: 264 seconds]
antkong has quit [Ping timeout: 256 seconds]
Guest8348 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
_andre has quit [Quit: leaving]
reem has joined #ocaml
larhat has quit [Quit: Leaving.]
ptc has joined #ocaml
ptc is now known as Guest75057
reem has quit [Remote host closed the connection]
reem has joined #ocaml
bytbox has joined #ocaml
reem has quit [Remote host closed the connection]
bytbox has quit [Ping timeout: 264 seconds]
tane has quit [Quit: Verlassend]
<haesbaert>
say I want given a list ['a'; 'b'] -> [ [
<haesbaert>
I can use something like that maybe, but it's probably simpler just to write one, I was wondering if there was such thing on Core.Std or Std
<companion_cube>
no idea, really
<companion_cube>
Core is bigger than Gen though ;)
<companion_cube>
(disclaimer: I'm the author of gen, so that's all self-promotion)
<haesbaert>
ah awesome :P, the thing is I'm already using core, so it's one less thing
<companion_cube>
so, you have a real use for combinations? :D
<thizanne>
I do have
<thizanne>
(but I need ordered combinations, so add ['b'; 'a'])
<haesbaert>
I actually do, I just want all combinations of my cat implementation, and then I run regress tests with all possibilities and compare again the openbsd cat
<haesbaert>
*against
<companion_cube>
oh, ok
<companion_cube>
well, a relatively naive implementation should do then
<companion_cube>
it's harder to work with thousands or more combinations
<thizanne>
can you do better than naive ?
pgomes has joined #ocaml
<haesbaert>
yeah, any simple/slow should do
vpm_ has joined #ocaml
<companion_cube>
thizanne: for iterators, you don't want to generate all the n! items if only a few are used
<companion_cube>
if you always generate all of them it's simpler
<companion_cube>
Drup: I don't know if it's good for OCaml or not
<companion_cube>
(the GC newes)
<companion_cube>
news
<Drup>
it means it's not there yet
<companion_cube>
ok :(
<whitequark>
"who knows"
<whitequark>
someone needs to implement a working backend first
<Drup>
didn't you mostly did that already ?
olauzon has joined #ocaml
<whitequark>
well, it had shitty value representation
<whitequark>
or rather, shitty allocation representation
<Drup>
well, that's at least something
<whitequark>
there's no value in using llvm if you don't let it lift allocations, do SROA, or inline
<whitequark>
it would quite likely perform worse than ocamlopt
<ollehar1>
could llvm perform better than ocamlopt, in any other circumstance?
<whitequark>
sure, llvm could do many interesting things
<whitequark>
it could SIMD-ize loops, of course after lifting allocations
<whitequark>
it could inline aggressively
<whitequark>
it could do SROA
<whitequark>
it could do inter-module optimization easily
<whitequark>
it could do LTO with C code, especially bindings
<ollehar1>
oh, ok
<whitequark>
it would allow you to ship to PNaCl
<ollehar1>
yeah, that would be cool.
<whitequark>
the key is teaching it to lift allocations
<ollehar1>
is that an accepted standard, PNaCl?
<whitequark>
most of its analyses are really useless in presence of many allocations
<whitequark>
no
<whitequark>
it's Google, in practice
<whitequark>
because FF is being idiotic and MS being what MS is
<whitequark>
"asm.js", my ass
<Drup>
:D
<ollehar1>
what's wrong with asm.js now?
<whitequark>
1) it's wholly unnecessary
<whitequark>
I could really stop here
<Drup>
I would probably not have say it like that, but I rather agree with you, asm.js is not such a fabulous idea
<whitequark>
no, it's literally unnecessary
<Drup>
said*
<whitequark>
for a long time, Chrome did not even recognize the annotation, and got more or less same perf
<Drup>
not really
<whitequark>
now it recognizes an annotation and fast-tracks the new engine that uses a sea-of-nodes IR for that function
<Drup>
the performances were not identical
<whitequark>
which will eventually get there anyway
<whitequark>
hence "more or less"
<whitequark>
it is still not going to implement the AOT or even any asm.js-specific passes
<Drup>
anyway, that's not really my problem with it
<whitequark>
the whole industry masturbates at asm.js because it's the latest fad
<Drup>
it's very ad-hoc
<whitequark>
it's just a formalization of emscripten output that some people who can't write a good JS engine have hardcoded to their browser
<whitequark>
as i've said, get over it already
<Drup>
"let's formalize what emscripten output and try to optimize it like it was C"
<Drup>
and, as expected, it really works only for C.
<whitequark>
a few sensible things came out of that, like mul64
reem has joined #ocaml
reem has quit [Remote host closed the connection]
<whitequark>
but the part where they use an AOT compiler is pointless
dav has quit [Ping timeout: 250 seconds]
<whitequark>
Drup: that's really the other side of my complaint
<whitequark>
if you don't optimize /specifically/ for asm.js, you don't lose perf in all the slightly differing cases
dav has joined #ocaml
<Drup>
this point was well hidden in you argument. :D
<Drup>
(in particular, you can't interact with the DOM in asm.js)
<whitequark>
you can't even allocate
<Drup>
(which makes it ... of rather limited usage)
<whitequark>
you can't return a string
<Drup>
yes
<whitequark>
or access an object read-only
<Drup>
(oh, you can't manipulate the stack to implement the call convention of ocaml, people tried n_n)
<whitequark>
hrm
<whitequark>
you mean, you can't trick it into doing tail recursion?
<whitequark>
it doesn't have an explicit notion of calling convention
<Drup>
that, and the various tricks for partial evaluation and currified things
<Drup>
you know, the two entry points in clojures
<whitequark>
right
<Drup>
maybe "manipulate the stack" was the wrong way to put it
jwatzman|work has quit [Quit: jwatzman|work]
<whitequark>
you could, uhm
<Drup>
haesbaert: still there ?
<whitequark>
Drup: you could CPS-convert it
<ollehar1>
häsbärt
reem has joined #ocaml
<whitequark>
well, not /quite/ CPS-convert it
<haesbaert>
Drup: yep
<whitequark>
emulate pushing and popping of return address by pushing or popping a function index in a global function table with all ocaml functions
<Drup>
whitequark: current js_of_ocaml do trampolines
<Drup>
(boing)
<Drup>
haesbaert: core :(
<whitequark>
and instead of properly using parameters, you would put those on an emulated stack
<haesbaert>
Drup: core is no juju ?
<whitequark>
but this sounds horrifying
<Drup>
haesbaert: what is the size of your cat executable ?
<haesbaert>
12M \o/
<haesbaert>
native
<Drup>
do you consider that acceptable ?
<haesbaert>
obviously not, but it's an exercise on learning the language, not producing something truly useful
ontologiae_ has quit [Ping timeout: 245 seconds]
<Drup>
learn cmdliner to replace Command ;)
<haesbaert>
will do, especially since Command doens't accept unix style: -abc, only -a -b -c
<haesbaert>
so without Core, what would have been the size of that ?
<haesbaert>
more or less
<Drup>
a few ko ?
<haesbaert>
ah cool
<haesbaert>
then it becomes useful
<Drup>
yes
<whitequark>
more like 200k
<companion_cube>
Drup: at least 600kB
<companion_cube>
or something like this
<haesbaert>
why does the compiler need to put the whole core implementation, even if I don't call most of the stuff
<Drup>
hum, I mean < 1M
<companion_cube>
at soon as you have dependencies
<Drup>
but you are right
<whitequark>
haesbaert: it's not a very optimizing compiler
<Drup>
dead module elimination is not that simple given the semantic of modules and the absence of main functions in ocaml
SIGILL has joined #ocaml
<companion_cube>
absence of main -> several roots, but apart from that?
<whitequark>
you could just not construct records for modules
<whitequark>
er
<companion_cube>
you could fill the never-used slots with 0
<whitequark>
I mean, you need to do DCE on global initializers too
<haesbaert>
to be honest, coming from a kernel hacking background, when I saw my cat with 12MB made me depressed.
<Drup>
companion_cube: because any side effect in a module is a root
<companion_cube>
yes, so? do that many modules have side effects?
<Drup>
I put a print somewhere in a module, it's a root
<Drup>
yes ?
<companion_cube>
oh
<Drup>
like, everywhere
<companion_cube>
hmmm, I'm not used to those
<whitequark>
this is not a problem really
<Drup>
whitequark: it's a problem *given the semantic of modules*
<companion_cube>
I don't think I write a lot of side-effectful modules (at least not in libraries)
<Drup>
the solution is to change the semantic -> module aliases
<smondet>
whitequark: it's the semantics of the module system, if Mod_name is referenced, you *need* to run all the toplevel definitions `let value = ...` which makes you link the module
<Drup>
but it's a different semantic.
<companion_cube>
you could link all the modules but prune their content
<Drup>
"let incr = let r = ref 0 in (fun () -> let x = !r in r := x +1 ; x)"
<Drup>
^ this is a root.
<whitequark>
smondet: but you could still prune unused functions from that module.
<Drup>
ah, yes, you could technically do that
<whitequark>
it's a global DCE problem
<whitequark>
you can do that with LTO.
<companion_cube>
↑
shinnya has quit [Ping timeout: 246 seconds]
<Drup>
except I'm affraid it won't be that much, in the end
<companion_cube>
anyway, good night
<companion_cube>
it should be a lot when you link against batteries, e.g.
<smondet>
computationally quite expensive to that kind of fine-grained dependency tracking
<Drup>
companion_cube: I'm pretty sure you are doing some, even if you don't realize :)
<whitequark>
smondet: it's already done for C++
<Drup>
companion_cube: batteries is exacty the example that doesn't work
<companion_cube>
a few
<Drup>
because it does *a lot* of side effects
<companion_cube>
it works if you prune unused content
<companion_cube>
not if you try to prune whole modules
<smondet>
whitequark: yes, g++ takes ages to compile
<whitequark>
it's not as fast as ocamlopt, sure, but it does solve the problem
<Drup>
no, even if you try to prune functions
<whitequark>
well, g++ is not exactly a speed demon :]
<companion_cube>
like, List.flat_map can be removed if unusued
<whitequark>
clang++ is a good comparison though
<Drup>
whitequark: MLton :p
<ousado>
haxe does global DCE, too
<Drup>
(js_of_ocaml too :D)
<ousado>
and is super fast
<companion_cube>
even jsoo does, doesn't it?
<companion_cube>
good night (again)
<Drup>
core_kernel is still atrociously big
<Drup>
(and batteries is rather big too)
<whitequark>
here, global DCE would require some more optimizations to be fully effective
WraithM has quit [Quit: leaving]
<whitequark>
though I'm not sure
<Drup>
I still think module aliases to be a better solution, by changing the semantic
<Drup>
to a more appropriate one for libraries
<whitequark>
not mutually exclusive
<Drup>
of course :p
<haesbaert>
btw, are there any caml4 developers in the channel ?
<Drup>
there are no camlp4 developers
<Drup>
:D
<whitequark>
there is no camlp4
<Drup>
(it's a joke, there is one, he was designated slightly against his will)
<whitequark>
there is still no camlp4
<whitequark>
that developer's struggle is a metaphor for battling his inner demons
<haesbaert>
who is it ?
shinnya has joined #ocaml
<whitequark>
like the rest of camlp4
<Drup>
(the first rule of #ocaml, "there is no camlp4")
<haesbaert>
I see
<Drup>
haesbaert: more seriously, what's the issue ? ^^'
<haesbaert>
none, I was just curious
<Drup>
camlp4 is, let's say, falling out of grace
struktured has joined #ocaml
<haesbaert>
what is camlp4 exactly ? the language ?
<Drup>
it's a preprocessor
<Drup>
wrapped in a library to combine parsers
<Drup>
(and to write them)
<Drup>
in order to do syntax extensions for ocaml
<haesbaert>
I see
<Drup>
haesbaert: line 70 is certainly not doing what you think it does
<Drup>
you think it will flush, do you ?
Haudegen has quit [Ping timeout: 250 seconds]
<Drup>
line 47 and 48 should probably be merged
<Drup>
(I don't really like the aliasing of functions, especially considering the names are not very nice)
<haesbaert>
ref line 70: hmm yeah it doesn't ?
<Drup>
nope, it doesn't
<Drup>
this doesn't call a function
<Drup>
it uses a value
<Drup>
a value equal to ()
<Drup>
the function was already applied line
<Drup>
27
<haesbaert>
I thought that would call oflush and eval to ()
<Drup>
no, you assume lazy evaluation
<haesbaert>
ahhh o
<haesbaert>
obviously
<haesbaert>
it's not a partial application on line 27
<Drup>
exactly
<Drup>
(I would advise to eta expand everywhere)
<haesbaert>
got carried away with the ochar stuff
<Drup>
(it would avoid this kind of issues)
<haesbaert>
eta = ?
<Drup>
transform "let f = g x" in "let f a = g x a"
<haesbaert>
the thing is, core stuff is too verbose: Out_channel.output_char Out_channel stdout c
<haesbaert>
starts looking like java
reem has quit [Remote host closed the connection]
<Drup>
module OC = Out_channel
<Drup>
;)
<Drup>
OC.(output_car stdout c)
<Drup>
char*
Guest19391 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<haesbaert>
btw is that equivalent to (OC.output_car stdout c) ?
<Drup>
OC.( ... ) equivalent to "let open OC in ..."
<haesbaert>
AHHHHHH
<haesbaert>
awesome, that's why you can cut the prefix in stdout