<Ramzi>
is writing a recursive descent parser easy in ebnf form?
<orbitz>
ebnf is just a way to represent a grammar
kopophex has joined #ocaml
<znutar>
It's not bad if the ebnf grammar is in LL(k)
<znutar>
if it's not in LL(k) then it might not terminate, and you'll need to add backtracking
love-pingoo has quit ["Connection reset by pear"]
|Catch22| has joined #ocaml
coucou747 has quit ["bye ca veut dire tchao en anglais"]
<det>
If you use an Int32 in a loop, will it be efficient, or will it be constantly unboxed? I need to implement CRC32 and RSync rolling checksum. I'd like to implement it in OCaml, but I wonder if it would be best to just rip the C and use the FFI.
<orbitz>
check out the md5 sum code and see what it does?
<det>
Wow, Int32 is implemented with FFI calls for each operation :/
<orbitz>
hot!
<det>
That's terrible.
<det>
Digest uses FFI, I guess I will have to as well.
prince has quit [Connection timed out]
kopophex has quit [Client Quit]
Kopophex has joined #ocaml
postalchris has quit [Read error: 110 (Connection timed out)]
yangsx has quit [Read error: 110 (Connection timed out)]
gaja has joined #ocaml
Demitar has quit [Read error: 110 (Connection timed out)]
<mikeX>
det: I implemented a crc32 in ocaml and it was much slower than the C version, can't recall exact numbers, but I think my program was CPU bound instead of IO bound
<mikeX>
det: I ended up using the FFI, it's pretty straight forward for small things like that
det has quit [Remote closed the connection]
det has joined #ocaml
jlouis has quit [Remote closed the connection]
Linktim_ has joined #ocaml
middayc has joined #ocaml
Linktim has quit [Read error: 110 (Connection timed out)]
Linktim_ has quit [Read error: 110 (Connection timed out)]
^authentic has joined #ocaml
naufraghi has quit []
coucou747 has joined #ocaml
Linktim has joined #ocaml
schme has quit [Remote closed the connection]
authentic has quit [Read error: 110 (Connection timed out)]
^authentic is now known as authentic
sporkmonger has quit []
naufraghi has joined #ocaml
LordMetroid has joined #ocaml
filp has joined #ocaml
Linktim has quit [Read error: 110 (Connection timed out)]
petchema has joined #ocaml
Linktim has joined #ocaml
sporkmonger has joined #ocaml
Linktim_ has joined #ocaml
munga has joined #ocaml
middayc has quit []
Linktim has quit [Read error: 110 (Connection timed out)]
Linktim has joined #ocaml
Linktim_ has quit [Read error: 110 (Connection timed out)]
^authentic has joined #ocaml
authentic has quit [Read error: 110 (Connection timed out)]
^authentic is now known as authentic
<ikatz>
anybody know how precedence works in ocamlyacc?
<ikatz>
lookahead is killing me and i have no idea what the documentation is saying
<ikatz>
in other words, i have a shift/reduce conflict
<ikatz>
and no idea how to get it to reduce instead of shift
RobertFischer has joined #ocaml
RobertFischer has left #ocaml []
RobertFischer has joined #ocaml
munga has quit ["Leaving"]
ktne has joined #ocaml
ktne has left #ocaml []
mikeX_ has joined #ocaml
mikeX has quit [Read error: 101 (Network is unreachable)]
Linktim_ has joined #ocaml
Linktim has quit [Read error: 110 (Connection timed out)]
ikaros has quit [Read error: 110 (Connection timed out)]
ikaros has joined #ocaml
pango_ has quit [Remote closed the connection]
Linktim_ has quit [Read error: 110 (Connection timed out)]
pango_ has joined #ocaml
Smerdy has joined #ocaml
Smerdyakov has quit [Nick collision from services.]
Smerdy is now known as Smerdyakov
Poulet_ has joined #ocaml
Poulet_ has quit [Client Quit]
svenl has quit []
svenl has joined #ocaml
<qwr>
hmm
<qwr>
what i should use, if i want to create custom-drawed widget in lablgtk2?
* qwr
looked at drawing_area, but it don't seem to take any draw callback?
Linktim_ has joined #ocaml
<qwr>
ah nevermind, found some example...
magthe has joined #ocaml
Morphous has joined #ocaml
Linktim_ has quit [Read error: 110 (Connection timed out)]
mikeX_ is now known as mikeX
<rwmjones>
qwr drawing area definitely
Linktim_ has joined #ocaml
Morphous_ has quit [Read error: 110 (Connection timed out)]
Linktim- has joined #ocaml
Linktim_ has quit [Read error: 110 (Connection timed out)]
<RobertFischer>
rwmjones: Ping. Just sent a mod_caml compile error to the modcaml mailing list.
<RobertFischer>
You can come up with your own code.
<RobertFischer>
You're smart enough to do that.
<bouzukist>
i do with if
<bouzukist>
if then .. else
<bouzukist>
if i have 1000 char list :s
<bouzukist>
will be complicated
<bouzukist>
i dont know how i do using rec
<RobertFischer>
What does "using rec" mean?
<bouzukist>
recursivity
<RobertFischer>
Sure. So the function is going to call itself, right?
<bouzukist>
let f rec (blabla ->blalva) = function ...
<bouzukist>
yes
<bouzukist>
sure
<bouzukist>
let rec (f:blabla ->blalva) = function ...
<RobertFischer>
Well, do you think it will recurse on the first argument or the second?
<bouzukist>
1st
<RobertFischer>
Okay. And what will change from one round of recursion to the next?
<bouzukist>
let rec (f:int * char list list ->char list) = function
<bouzukist>
how i continue i dont know with using same function
<bouzukist>
if my int is 1 will give me 1st char list
<bouzukist>
...
magthe has quit ["Ex-Chat"]
<RobertFischer>
Well, you're not going to call the exact same function with the exact same arguments -- that'd get you into some infinite recursion, and that's no good.
<rwmjones>
RobertFischer, you're on some sort of 64 bit arch ... which one?
<RobertFischer>
rwmjones: Intel, I'm pretty sure. Got a Unix cmd that would tell me for sure?
<rwmjones>
yeah, intel copied their 64 bit arch from amd
<rwmjones>
(unless you mean itanic ... but no one uses that!)
<RobertFischer>
No, not Itanic.
<rwmjones>
uname -a ?
<RobertFischer>
Okay, so I'll do this patch, and then life will be good.
<rwmjones>
you just need to compile that one file
<bouzukist>
allo
<rwmjones>
then copy libcamlrun.so into ocamllibdir
<RobertFischer>
"x86_64 GNU/Linux". Not helpful.
<rwmjones>
RobertFischer, x86_64 is amd64
<rwmjones>
the latter is what debian call it
<RobertFischer>
I thought x86_64 was the generic 64-bit Pentium derivative (including both Intel and AMD).
<RobertFischer>
bouzukist: Instead of doing if/then statements, try a different approach. Try to handle the one case you care about (returning the value), and then recursing on a slight change to the first argument.
<bouzukist>
how :(
<bouzukist>
its my 1st day using rec
filp has quit ["Bye"]
<RobertFischer>
bouzukist: Well, how would you have a function call itself?
<bouzukist>
f(c,l)
<RobertFischer>
Say I want to create a function f: int -> unit which prints out the numbers from the argument down to 1. So, f 10 would print out "10 9 8 7 6 5 4 3 2 1".
<RobertFischer>
How would you do that?
<RobertFischer>
(Using recursion, of course.)
<bouzukist>
ur not understanding
<bouzukist>
:s
<RobertFischer>
I think if you solve my question, your problem will be solved in a very similar way. :)
<orbitz>
stop not udnerstanding RobertFischer !
<bouzukist>
(x) -> x::f(x-1) ;;
<orbitz>
that makes a list, doens't print it
<RobertFischer>
But it's the same principle. Digging at the right spot.
<bouzukist>
so
<bouzukist>
i dont see my problems :(
<RobertFischer>
Well, you're not using recursion, and you're supposed to.
<RobertFischer>
So that's the problem with the solution you pastied out here.
<orbitz>
sweet mama
<orbitz>
is this the acctual code?
<bouzukist>
yes
<RobertFischer>
(bouzukist is obviously new to programming.)
<bouzukist>
but i donr know how to convert it to rec
<bouzukist>
i'm
<orbitz>
what is the assignment?
<RobertFischer>
Well, you're going to call the same function. And you've already decided you're recursing on the first argument, so the function is going to call itself with a slight change to the first argument.
<bouzukist>
yes
<bouzukist>
then ?
<RobertFischer>
Then you're pretty much done. :)
<RobertFischer>
What's the slight change to the first argument you're going to do?
<bouzukist>
1 sec ill chek some codes
<orbitz>
is he writing his own List.nth?
<RobertFischer>
orbitz: More or less.
<orbitz>
bouzukist: get that?
ziph has joined #ocaml
<RobertFischer>
orbitz: He needs the code to be recursive for the assignment.
<bouzukist>
(x, l) -> if x=0 then List.hd(l) else f((x-1), (List.tl(l) );;
<bouzukist>
working
<orbitz>
bouzukist: what if l is [] ?
<orbitz>
that's good though
<bluestorm>
bouzukist: at least, please don't lie
<bluestorm>
[18:59:43] <bouzukist> its my 1st day using rec
<bluestorm>
you asked us for a recursive function on April 7
<bluestorm>
[mer mar 26 2008] [21:39:51] <bouzukist> i coding since 2 months
<orbitz>
owned
<bouzukist>
maybe
<bouzukist>
but not with rec
<bluestorm>
[lun avr 7 2008] [18:55:41] <bouzukist> [a;b;c;d;e;f;g;h;i;j;k;l] comment a partir de char list je peu avoir en recursivité [(a,b);(a,c);(a,d);(a,e);(a,f)...(a,l)]
<bouzukist>
yes that true
<bouzukist>
but i dont know how we do .. today we started to learning
yziquel has joined #ocaml
OChameau has quit ["Leaving"]
<bluestorm>
bouzukist: using the code coucou747 gave you, i think let rec f(n, li) = if n=1 then List.hd(li) else f(i-1, List.tl(li));; should be what you're waiting for
postalchris has joined #ocaml
<ziph>
We're doing the thing where we put 1 error in all homework question answers, right?
<bluestorm>
?
<ziph>
The thing where we put an error in to keep students on their toes.
<ziph>
(wink wink)
bouzukist has quit []
<bluestorm>
heh, he left
<RobertFischer>
Well, he got his answer, apparently.
<ziph>
I hope he cuts out the "using the code coucou747 gave you," bit.
<RobertFischer>
It was getting tough to give him hints without giving him the answer.
<RobertFischer>
ziph: LOL. I'd hope.
<bluestorm>
RobertFischer: i bet he wouldn't have left until someone gave the complete code
<bluestorm>
i don't think he actually knows how to write caml functions anyway
<RobertFischer>
Then it sounds like a good time to learn.
<coucou747>
ziph> wtf ?
<bluestorm>
(at least he couldn't last month)
<coucou747>
bluestorm> j'ai fait une connerie ?
<ziph>
coucou747: sorry?
<bluestorm>
non
<RobertFischer>
Yeah. When I was a TA back in college, I got really mad at people who just declared that they didn't know what was going on. You could watch their brains shut down through their eyes. It was sad and extremely frustrating.
<coucou747>
I hope he cuts out the ... what it means ?
<coucou747>
j'espere qu'il ?
<ziph>
Ah.
<bluestorm>
actually
<ziph>
coucou747: I hope he doesn't think "using the code coucou747 gave you, i think" was part of the source code and then include it in his assignment. :)
<ziph>
(from "bluestorm: bouzukist: using the code coucou747 gave you, i think let rec f(n, li) = if n=1 then List.hd(li) else f(i-1, List.tl(li));; should be what you're waiting for")
<bluestorm>
once a friend of mine printed a whole log of instant messaging where i was explaining him the homework, and absent-mindedly gave it to the teacher with his own work
^authentic has joined #ocaml
<orbitz>
haha
<ziph>
RobertFischer: I've had to work with people like that.
<orbitz>
at what point do we on IRC do we say "you just dont' get it and i can't do your homework to you" cuz the problem is persistent generally pays off for the dull minde don IRC, someone just gives them teh answer
<Smerdyakov>
You should first ask about the homework policy for the class.
<Smerdyakov>
Many classes allow _zero_ help from Internet people.
<Smerdyakov>
If you don't do this, you have to accept that you are usually helping people cheat.
<bluestorm>
orbitz: i think in this very case, he wouldn't have left until he got the answer anyway
<RobertFischer>
ziph: I just want to scream with people like that. "You -- you no longer have a right to all that brainpower. I'm confiscating your brain and giving it to someone who is going to give a damn."
<coucou747>
if we do homework for olther people, they loose more than us
<acatout>
Smerdyakov: Good point, but the student could lie about that.
<orbitz>
bluestorm: does that mean we should give him the answer?
<bluestorm>
i have to admit that, being selfish, i prefer to write a little line of code and see him leave
<orbitz>
bluestorm: +q is probably more efficient
<Smerdyakov>
acatout, most people asking for help in such situations are skillfully avoiding thinking about whether they are cheating. Requiring them to make an explicit statement forces them to confront it.
<ziph>
The answers don't have to be correct.
<coucou747>
orbitz> it's not so important...
<coucou747>
it's just homework
<bluestorm>
ziph: difficult to insert an error in a so simple function, but i'd be glad to hear your suggestion next time
<Smerdyakov>
And there is also the fact that most people here are very bad teachers.
<bluestorm>
and actually i think that not handling the [] case was a kind of error
<Smerdyakov>
Even outside a formal class policy with academic codes of conduct, you do people harm by preventing them from learning anything.
<ziph>
bluestorm: Anything that looked kind-of right would've probably worked.
<bluestorm>
but it has to pass the unit-test
<ziph>
Ah. Hmmmm.
<ziph>
Have it redefine the "assert" function.
<bluestorm>
i'm not really interested in tricking him anyway, just lazy
<ziph>
Maybe give them the answer to a different but related problem...?
<bluestorm>
hm
<bluestorm>
let rec f(a, b) = if a < 0 then [] else List.nth (a-1, b) might be what you're looking for, ziph
<orbitz>
ha
<Smerdyakov>
We need to have a unified approach here. I suggest: 1) Ask about the class' homework policy. 2) If help from IRC folk is allowed, ask questions about what he knows and try to figure out which basic concepts he is missing, rather than just giving the answer.
<ziph>
Getting a reliable answer for 1) could be a problem.
<bluestorm>
Smerdyakov: and if he admit violation of the homework policy or admit knowing totally nothing, and keep asking ?
<orbitz>
I guess it depends on if people in the channel think it's more productive to get someone like the previous guest out of here or if you should pu the effort into teaching them osemthing
<Smerdyakov>
bluestorm, in the first case, tell him to stop trying to cheat here, and ban/silence if he ignores it. In the second case, tell him to go talk to his course staff.
<orbitz>
the previous guest might ismply have not gotten it no matter how much effort you put it, and mos tlikely would not have left unless everyone /ignore'd him. but that' sjus ta guess
<Smerdyakov>
ziph, no, I don't think so. Most people don't want to admit to themselves that they're cheating.
<bluestorm>
isn't giving the answer simpler than a ban/kick ?
<Smerdyakov>
bluestorm, giving the answer has tangible negative consequences for the questioner's classmates.
<bluestorm>
ha ?
<Smerdyakov>
bluestorm, and tangible negative consequences for the questioner's learning process, even outside of a formal class.
<ziph>
bluestorm: And Karma will make your boss hire the guy once he graduates. ;)
<bluestorm>
i'm very ignorant of US class evaluation methods
<orbitz>
bluestorm: in most US college's, a strong homework grade can make the difference beween pass and fail
<Smerdyakov>
bluestorm, the second point should be important enough for you to change your ways. :)
<bluestorm>
hm
<bluestorm>
i you think it's better, i can stay silent next time ^^
<orbitz>
hah
<bluestorm>
Smerdyakov: actually i don't really care about the learning process of someone who's been brainlessly asking stupid questions here for three times, and never showed any will to learn something
<Smerdyakov>
bluestorm, then the right answer is to ban/silence that person, not keep answering, which adds noise for the rest of the channel participants.
<bluestorm>
last time there was a parent missing in his code, and he asked us three time what the problem was
<bluestorm>
(actually he didn't asked about the problem, but for the correct answer)
<bluestorm>
i don't have the privilege to ban anyone, but i can certainly do nothing next time
<orbitz>
haha
<orbitz>
i like silencing people, someone like the previous person would probably not realize they are silenced and not try to evade it
<orbitz>
it's more effecive IMO
<orbitz>
but my /ignore list doesn't appear to have any limits
authentic has quit [Read error: 110 (Connection timed out)]
^authentic is now known as authentic
<ziph>
bluestorm: I don't care either by the way. The half hour meta-discussions are more obtrusive than the students. ;)
<bluestorm>
:D
<Smerdyakov>
There's no need for half-hour meta discussions with a common policy.
<Smerdyakov>
I'm often tempted to silence people who give help inappropriately, but that's probably a bad idea politically.
<bluestorm>
:]
<orbitz>
guess you gotta define inapproriate first
* RobertFischer
hides.
<Smerdyakov>
It's very easy to define.
<bluestorm>
Smerdyakov: it seems RobertFischer share your point of view on "not giving the answer", so i guess we can consider your proposition as a common policy
<orbitz>
let's take 2 years and write an IRC bot that i capable of simulating homework discussion and forward them to a channel that these bot sli vein so they won't know
<RobertFischer>
I just refuse to enable people to be lazy and willfully stuipd.
<RobertFischer>
(stupid)
<bluestorm>
i'm not sure they need your agreement
<ziph>
Stuipd sounds like what happens after a night of drinking.
<RobertFischer>
And right now, I'm asking for help on the mod_caml list (rwmjones ping again), so it'd be tacky to not provide help. Call it what you will, but I've found the best way to get what you want is to give what you want. :)
<Smerdyakov>
It's just disingenuous to pretend that it's not easy to distinguish the questions of students, who for the most part don't actually care about learning OCaml.
<RobertFischer>
I'm not pretending like they care. But I'm also not feeding them the answers.
Linktim_ has joined #ocaml
<orbitz>
maybe we should use John Harrop's shepherd story for peole like that :)
Linktim- has quit [Read error: 110 (Connection timed out)]
sporkmonger has quit []
postalchris has quit [Read error: 110 (Connection timed out)]
Linktim_ has quit [Read error: 110 (Connection timed out)]
postalchris has joined #ocaml
|Catch22| has joined #ocaml
yziquel has quit [SendQ exceeded]
yziquel has joined #ocaml
postalchris has quit [Read error: 110 (Connection timed out)]
ziph has quit []
ChristopheT has joined #ocaml
jimwhite has joined #ocaml
postalchris has joined #ocaml
|Catch22| has quit ["To the best of my knowledge, I guess that I'm fresh"]
<postalchris>
Is there a way to post to caml-list w/o getting the emails? (I prefer to follow on fa.caml)
coucou747 has quit [Read error: 104 (Connection reset by peer)]
eelte has joined #ocaml
yziquel has quit [SendQ exceeded]
yziquel has joined #ocaml
zobilacho has joined #ocaml
yziquel has quit [Connection reset by peer]
jlouis has joined #ocaml
naufraghi has joined #ocaml
filp has joined #ocaml
<kig>
wonder what would be a good atrivial trivial-to-implement web framework benchmark. maybe something like "parse request into sql query, open db, fetch 100 10-column rows from database, create html table of the escaped data."
<bluestorm>
i guess the developper of the framework would be more interested in separate benchmarks for the different components
<kig>
that's true
<kig>
the db stuff is going to add 5-25ms overhead, that would be nice to isolate at least
<bluestorm>
moreover, i guess most part of Ocsigen have not been optimized yet, so i'm not sure you would get a really meaningful result, while an early publication of thoe results might hurt someway
<bluestorm>
(removing the rethoric, the content of my objection is more or less "let's not publish benchmark unless they are good")
<kig>
the xhtml.m documentation page hurts more though
<kig>
not only is it nearly useless, it breaks firefox too :]
<kig>
publishing good benchmarks is.. well, you could make a hello world benchmark, ocsigen is faster on that than a cgi script written in asm
<kig>
0.89ms vs 0.96ms or something like that
<bluestorm>
:p
Linktim- has joined #ocaml
<kig>
(oh the things you do to keep procrastrinating)
RobertFischer has joined #ocaml
RobertFischer has left #ocaml []
RobertFischer has joined #ocaml
zobilacho is now known as yziquel
schme has joined #ocaml
ikaros has quit ["segfault"]
filp has quit ["Bye"]
schme has quit [Remote closed the connection]
schme has joined #ocaml
Linktim_ has joined #ocaml
ChristopheT has quit [Remote closed the connection]
<orbitz>
i see in a jocaml exampel they do let () = Join.Site.listen addr
<orbitz>
anyone know why?
<bluestorm>
why what ?
<orbitz>
why do they give unit a new value? (that is what it does right?)
<bluestorm>
Is the "let () =" idiom puzzling ?
<bluestorm>
ah
<bluestorm>
orbitz: no that isn't :p
<orbitz>
oh, what is the idiom then?
<RobertFischer>
That's "main" in Ocaml-ese.
<bluestorm>
actually, the left part of a "let" is not a variable
<bluestorm>
it's a pattern
<bluestorm>
a variable name being a pattern, you usually see a variable here
<bluestorm>
but you could consider "let foo = bar in foobar" to be equivalent to "match bar with foo -> foobar"
<orbitz>
that makes sense to me as function parameters like let main () = ..
<orbitz>
wouldn't the be similar to let 5 = foo?
<bluestorm>
let () = ... is only a way to say "i acknowledge that the my value is unit, and i want it evaluated right now"
<bluestorm>
orbitz: let 5 = foo would raise a match failure if foo doesn't evaluate to 5
<bluestorm>
but let 1 = 1 is valid
<orbitz>
oh
<bluestorm>
(try let 1 = 0 )
<bluestorm>
and of course
<orbitz>
so does this just call Join.Site.listen and ensure it returns unit?
<bluestorm>
let 1 = "bar" would raise a type error
<bluestorm>
yes
<bluestorm>
but actually let () = ... is an idiom commonly used to say "main"
<orbitz>
is this preferred over Join.Site.listen addr;;?
<bluestorm>
yes, because it's declarative
<RobertFischer>
Of a sort. :)
<orbitz>
why does that make it better?
<orbitz>
the ocaml manual chooses let main () = ...;; main ();; which is probably the source of my confusion
<orbitz>
also, i think i'm still confused abotu when a ;; is needed and when it is not. the ocaml manual seems to put a ;; on any top level let that does not have an inner let, but the jocaml example does not
Linktim- has quit [Read error: 110 (Connection timed out)]
<bluestorm>
orbitz: i think the only case were ;; can be needed is when you have expression as toplevel phrases
<bluestorm>
and as you can translate them into declaration with that "let () = ..." idiom, i never use them
<orbitz>
the ;; aren't actually needed except for the main ();;
<orbitz>
you probably can't read minds, but do you have any idea why the manual seems to use this?
<bluestorm>
because they used the toplevel before
<orbitz>
before?
<bluestorm>
apart from 1.9, all that page use the toplevel as a way to evaluate ocaml phrases
<bluestorm>
as the ;; are mandatory inside the toplevel, removing them in the last section would (i suppose so) disturb the reader
<orbitz>
ok, just tryign ot be consistent
<orbitz>
thanks bl
<bluestorm>
(btw, do you know about tab completion on irc ?)
<orbitz>
i do which is why you got funky char there, my ssh lagged and it doesn't udnerstand tab when it does that
<bluestorm>
ok
* orbitz
starts getting ri dof ;; in code
<bluestorm>
that's a shame : it's always funny to watch the tab-completion-enlightenment
<orbitz>
i've been IRCing longer than i'd like to think, i know mos tof the tricks:)
<orbitz>
on the mailing list some peopel mentioned they would like an Int/Float module so you could move int_of_string o Int.of_string. i think that is a good idea but do you think a convention of a module should only have of_<type> functions so you avoid Int.to_string and String.of_int?
alexyk has joined #ocaml
<alexyk>
greetings -- how do I sort a DynArray?
<RobertFischer>
Smerdyakov: I think this one is for you. :)
<orbitz>
is DynArray part of the standard? I don't see it
<RobertFischer>
orbitz: Doesn't it make more sense to have the "to_<type>" functions? After all, when I'm converting to something, I'm going to be using public constructors on their side, but probably using some kind of impl details on my side.
<bluestorm>
orbitz: it's in ExtLib
<bluestorm>
RobertFischer: i was actually going to give some code :D
<bluestorm>
(could i ? it really doesn't look like a homework-related question)
<orbitz>
i don't see why not
<orbitz>
RobertFischer: sure to_<type> makes sense too
<bluestorm>
alexyk: you could use the conversion functions
<bluestorm>
for example convert it to an array, sort it, and convert back
<alexyk>
argh! it's huge already
<orbitz>
that's how i shuffle a list
<orbitz>
alexyk: you could add elements to it sorted
<bluestorm>
alexyk: would using a list instead of an array be better ?
<bluestorm>
i'm not sure why you consider the size of your dynarray as a problem
<bluestorm>
(unless it except the maximum size of arrays)
<bluestorm>
s/except/exceed/
<orbitz>
bluestorm: maybe he thinks making an array out of it and sorting that woudl be too costly? (double the memory in worst case right?)
<bluestorm>
it's a high-level method so, yes, it's a bit costly, but "generally" it looks like the good way to do it
<alexyk>
yes I just wonder why sorting a dynarray is not in the module
<alexyk>
I don't want to copy arrays just to sort them
<RobertFischer>
alexyk: Why not? GC is fast in Ocaml.
<alexyk>
well -- what's the rationale for having sort for an Array but omitting it from DynArray?
Demitar has joined #ocaml
<bluestorm>
alexyk: i'm not sure there is one; if you want to create a DynArray-specific sort and submit it to the extlib devs, it could get commited
<bluestorm>
but the state-of-the-art method is to convert this datastructure to a sortable one
Demitar_ has joined #ocaml
Demitar_ has quit [Read error: 104 (Connection reset by peer)]
<bluestorm>
(and if you think with genericity in mind, it's one of the best methods)
<alexyk>
this just confirms some strange pattern in OCaml libs vs eg Ruby which have all the expected things in the right places... (mumbling, hacking sort in unnatural ways...)
<bluestorm>
(eg. i don't think we should implement "filter" on arrays, because list is the natural data structure for filters, so it's not too bad to convert your array to a list and back if you want filter)
<bluestorm>
alexyk: i doubt you can have a general (that would suit everyone) definition of "expected"
<bluestorm>
for example, haskell has a very rich standard lib, but i actually quite often think of little functions that are not in the lib
<alexyk>
well Ruby kinda feels meeting the expectations, it's not called a programmer's best friend for nothing :)
<orbitz>
i guess alexyk's point is probably that sorting just-sorta-works in ruby/python etc
<alexyk>
orbitz: yep
<orbitz>
you don't need to be concerned if your type can be sorted
<alexyk>
ah I see -- the price of typing
<bluestorm>
that's not related to typing
<alexyk>
well DynArray wants to serve all types, unsortable too
<alexyk>
and we don;t have type classes... hmm
<bluestorm>
a type isn't sortable "per se"
<RobertFischer>
In Ruby, you'd have to pass in a sort function. That's not a bad way to do it in Ocaml.
<alexyk>
can dynarray be extended witha functor to generate a dynarray of sortable types with sort?
<orbitz>
alexyk: is there any reason you can't insert into your dynarray sorted?
<orbitz>
is that too expensive?
fremo has quit [Remote closed the connection]
fremo has joined #ocaml
<alexyk>
surely I can -- I just digress into ephemeral here :)
<bluestorm>
alexyk: you could just extend DynArray with a sort function, couldn't you ?
<alexyk>
fails for non-comparable types... I guess minimalism comes from type purism
<alexyk>
my guess
<bluestorm>
i feel an agressive smell in your "type purism" words
<bluestorm>
anyway, there is nothing related to types here
<pango_>
how do you sort without a compare function
<bluestorm>
the obvious way to sort something generically is to use a compare function
<orbitz>
RobertFischer: i imagine ruby has all the superficial things in the right places, to suck you in
<RobertFischer>
Yup. It's a bit higher-level, too.
<alexyk>
bluestorm: thx! no smell, just spring :)
<RobertFischer>
pango_: How do you know how to sort without a compare function?
<pango_>
RobertFischer: exactly
<bluestorm>
module DynArrayWithSort = struct include DynArray let sort cmp darr = of_array (Array.sort cmp (to_array darr)) end
<orbitz>
i think people that goto languages like python/ruby and view dynamic typic as a plus are most likely simply not aware of the powerful typing of somethign liek ocaml.
<orbitz>
we get all the power that dynamic typers want, with non of the pain
<qwr>
RobertFischer: you're absolutly correct, DSL and API _are_ in essence synonyms
<qwr>
RobertFischer: just DSL's might be a API with nicer syntax sometimes
<qwr>
but good apis always define dsl's
LordMetroid has quit ["Leaving"]
<qwr>
(and ML/haskell style functional languages have a alternative tool for nicer-looking apis - combinatoric libraries)
naufraghi has quit [Read error: 104 (Connection reset by peer)]
naufraghi has joined #ocaml
<RobertFischer>
qwr: I don't need the classes to be functionally identical. I was illustrating duck typing, not trying to port Ruby code identically into Ocaml.
<RobertFischer>
I was also trying to stay idiomatic for both languages.
<qwr>
and then you were line-counting them ;)
* qwr
really don't know what idiomatic ruby is
<qwr>
but then, i probably don't write really idiomatic code in any language...
jimwhite has quit []
<RobertFischer>
I'm following the Rails conventions for idiomatic stuff.
dlomsak has joined #ocaml
<RobertFischer>
If I wanted just the minimum of functionality, it would actually add a couple more lines to the Ruby code, and it'd be non-idioimatic.
<gildor_>
RobertFischer: i need some more information about a bug you open on forge.ocamlcore.org
<RobertFischer>
But I figured going with shorter, more idiomatic code was better, even if there was a slight (unused) API difference.
<RobertFischer>
Oh. I haven't fought with that recently.
<RobertFischer>
What information are you looking for?
<gildor_>
I cannot reproduce the bug at all
<gildor_>
i think you have a mac
<RobertFischer>
Yup.
<RobertFischer>
In that my Linux laptop wouldn't actually talk to my speakers and just barely managed to connect to the internet after 3 days of fighting with it, I punted over to Macville.
<gildor_>
do you use "ssh" with other location
<RobertFischer>
Yes.
<RobertFischer>
I use ssh a lot.
<gildor_>
(from your mac)
<RobertFischer>
Yes, from my Mac.
<RobertFischer>
I was actually just able to check out.
<RobertFischer>
So I'm not sure what the problem was, but it's intermittent.
<RobertFischer>
I'll let you know if it happens again.
<gildor_>
you mean that for now everything is ok
<qwr>
RobertFischer: hmm, what code it would add? I deleted the accessors and it still gives exactly the same output...
<RobertFischer>
gildor_: Yes.
<RobertFischer>
qwr: I'd have to specify the readers and writers I want on separate lines. Let me check the code again -- I've forgotten exactly what it looks like.
<qwr>
RobertFischer: the point is, you don't seem to use any of the readers/writers ;)
<RobertFischer>
When I get into griping about passing around blocks, it's actually not true anymore. The 1.8 version of Ruby fixed the problem by allowing &.
<RobertFischer>
I don't?
<gildor_>
RobertFischer: ok, i close the bug with a comment, reopen it if you have problem again and a way to reproduce this problem which i or you can test
<RobertFischer>
That saves one line on the Ruby code.
<qwr>
2 and the overall linecount ratio will stay same
<RobertFischer>
Oh, right, we've got two classes. :)
<qwr>
just little less possibility for rubysts to complain :P
<RobertFischer>
The big accusation (which is correct) is that I put a lot more stuff on one line in the Ocaml version, and I put them on separate lines in the Ruby version.
<RobertFischer>
And if you count characters, Ruby is actually the solid winner.
<RobertFischer>
It's just that the Ruby idiom is to have distinct statements on separate lines, and the Ocaml idiom is to have distinct *declarations* on separate lines.
<bluestorm>
btw, why didn't you use inheritance ?
* qwr
actually don't write ocaml that way
<RobertFischer>
bluestorm: Because I was demonstrating duck typing. See the link in the article about whether or not using inheritance is a good idea in that case anyway.
<qwr>
over-long ; sequences on one line seem somewhat unreadable to me
<RobertFischer>
Granted. But two or three ;s in a line are pretty common to see, particularly in object impls like that one.
<RobertFischer>
Been fighting that one out since 2005. :)
<bluestorm>
hmm
<bluestorm>
i thought that the liskov principle was not, in OCaml OOP, translated in terms of inheritance, but subtyping
<RobertFischer>
That post was applying Liskov to Java.
* qwr
too have found weird here, how people try to create class hierarchies in ocaml...
<qwr>
bluestorm: ocaml has structural typing. so anything that looks like subtype practically is subtype.
<qwr>
or you meant, that using inheritance would have saved few lines of code in ocaml?
<bluestorm>
qwr: yet it isn't necessarily substituable in the Liskov sense, is it ?
<bluestorm>
yes
alexyk has quit []
<bluestorm>
from my point of view (disclaimer : i've never really practiced ocaml oop) ocaml inheritance in only an "implementation inheritance", and all the philosophical "what is what and what else" are related to the subtyping relation, not inheritance
<qwr>
yes ;)
hsuh has joined #ocaml
hkBst has quit ["Konversation terminated!"]
alexyk has joined #ocaml
postalchris has quit [Read error: 110 (Connection timed out)]