<christo_m>
i need someone to tell mewhats wrong with MY code
<vixey>
you can't figure this out on your own?
<christo_m>
vixey: no
<vixey>
well I can look at it tommorow if I am on
<christo_m>
its due 10:30 am
<christo_m>
tmw
<vixey>
not that it means I will know how to fix it
<christo_m>
its probably something real simple
<christo_m>
can i just pm u with the source
<vixey>
ok
<christo_m>
vixey: ? pm
<vixey>
well did you try deleting the comment
<christo_m>
why would that matter
<vixey>
ok don't try it
<vixey>
don't bother, it's way too much effort
<christo_m>
vixey: i just did, same problem
<christo_m>
i was just wondering why it would matter, its omitted by the interpreter anyway
<christo_m>
vixey: any ideas?
christo_m has quit ["leaving"]
christo_m has joined #ocaml
<christo_m>
vixey: my bad, internets real bad here
<christo_m>
vixey: did you have any other ideas
<vixey>
yeah put lots of brackets around things
<christo_m>
lmao
<christo_m>
vixey: hows that any better than just having a bunch of semicolons everywhere
<vixey>
it might tell you why
<christo_m>
..
<christo_m>
okay if ur trying to teach me a lesson, please
<christo_m>
ill just revert to all semi colons and hand that in instead..
<christo_m>
because it was working before
<vixey>
I'm just telling you what I would try
<Camarade_Tux>
I only quickly took a look at your paste (and at the irc backlog) but I think you're missing semicolons between line 19 and 25
<christo_m>
Camarade_Tux: that's apparent, im just not sure where
<christo_m>
i was messing around with it, still wont work
<Camarade_Tux>
vixey, if you can't see his paste, he is using if/then/else, with unit-returning statements :)
<christo_m>
hmm..
<Camarade_Tux>
also,
<Camarade_Tux>
#
<Camarade_Tux>
raise Queue_full
<Camarade_Tux>
#
<Camarade_Tux>
myq.back <- 0
<christo_m>
i didnt use max_length even tho i defined it, i was using magic numbers again LOL, just noticed that now
<Camarade_Tux>
first, you can't put it that way, then you're doing something after raising an exception...
<christo_m>
Camarade_Tux: (sigh), i dont see where to put them..
<Camarade_Tux>
christo_m, what is sure is you have a problem with lines 21 and 22 : once you've raised your exception, nothing that is written below your raise gets executed
<Camarade_Tux>
when you're not sure about when to put semicolons, keep the let _ = ... in construct, it will usually be easier to spot errors and you are sure you're not messing with scopes (which is classical error when an if/then/else construct starts with an unit-returning statement)
<doy>
christo_m: double semicolons are basically never necessary, single semicolons are, occasionally
<Camarade_Tux>
off to bed now !
Camarade_Tux has quit ["Leaving"]
<christo_m>
doy: ok its almost there
seafood has joined #ocaml
christo_m has quit ["it works!"]
jeddhaberstro has quit []
mfp has quit [Read error: 110 (Connection timed out)]
<Axle>
christo_m: first off, your queue record doesn't have a height value
<doy>
palomer: it leaks here
<doy>
from ~6mb to ~25mb in a minute
<doy>
and still growing, although slowly
<palomer>
hrmph
<doy>
~43mb in 3 minutes
<doy>
should it not be leaking?
<palomer>
of course not
<palomer>
look at the code!
<doy>
well, sure
<palomer>
it's really simple
<doy>
(:
<doy>
i meant was it not expected
<palomer>
all it does is add and remove 2000 text entries every 100ms
<palomer>
well...
<palomer>
I can reproduce the problem in vanilla gtk
<palomer>
brb
palomer has quit ["Leaving"]
Palace_Chan has joined #ocaml
<Palace_Chan>
im trying to write a function which returns unit and appends its argument to an accumulator list declared before the helper function as in: let a = [] in let helper t : unit = t :: a; ()
<Palace_Chan>
but it wont let me semicolen the cons op...and if i dont semicolen it...it takes it as the return value
<Palace_Chan>
is there a way to do this ?
<doy>
well, the type of the function isn't unit
<doy>
it's something -> unit
<doy>
try removing the type annotation
<tsuyoshi>
let helper = let a = ref [] in (fun t -> a := t; ())
<tsuyoshi>
er
<doy>
oh, and you should be using references, yeah
<tsuyoshi>
let helper = let a = ref [] in (fun t -> a := t :: !a; ())
palomer has joined #ocaml
<palomer>
willing to run/compile a C program?
<doy>
sure
<Palace_Chan>
tsuyoshi, and the next time i call that functioon itll still have that first t in it ? even though your saying a = ref [] every time ?
<doy>
Palace_Chan: you aren't saying a = ref [] every time
<doy>
you're saying that when you get to that statement, and then storing the resulting function in helper
<tsuyoshi>
well.. if you add some formatting to make it easier to understand it's like:
<tsuyoshi>
let helper =
<Palace_Chan>
the helper function first let a = ref [] in (a is a local reference to an empty list), it then has fun t -> a := t :: !a; ()...what does calling helper do
<tsuyoshi>
let a = ref [] in
<doy>
palomer: no memleak in that one
<tsuyoshi>
(fun t ->
<doy>
oh wait
<doy>
it plateaus
<tsuyoshi>
a := t :: !a;
<tsuyoshi>
()
<tsuyoshi>
)
<doy>
yeah, definitely a memleak
<doy>
it seems to be holding steady at ~15mb at the moment
<Palace_Chan>
tsuyoshi, hmm but helper doesnt take an argument....essentially im trying to grab all the keys from a hashtbl and put them in a list...so i was thinking of calling iter with a function that just appends to a list every time its first argument
<doy>
oh, now it's going up again
<doy>
Palace_Chan: helper is being assigned the anonymous function
<doy>
which does take an argument
<palomer>
doy, yeah, it does that
<palomer>
ok
<Palace_Chan>
oh i see, helper = function from t to doing that
<tsuyoshi>
oh if you want to call iter then there is a much better way
<Palace_Chan>
tsuyoshi, is there ? i didnt find something in the Hashtbl library which seemed more immediate
<tsuyoshi>
let hashtolist h = Hashtbl.fold (fun k d x -> k :: x) h []
<Palace_Chan>
tsuyoshi, ohhhh the infamous folding, very nice (one of the things that is hard to get used to, im new to ocaml)
<palomer>
yay for folding!
<Palace_Chan>
i hope one day functional programming just clicks better - and these nice little constructs come to mind more often than battling the typechecker to death
* palomer
is doing research on this
<palomer>
if I could get this (*&(* memory leak fixed, id be one step closer to this goal
hudini has joined #ocaml
<hudini>
how do i use if then else with multiple lines
<palomer>
if foo then begin some;lines;baby end else begin some ; other; lines end
struktured__ has quit [Read error: 60 (Operation timed out)]
<tsuyoshi>
I prefer to use parentheses.. if foo then (some; lines; baby) else (some; other; lines)
<hudini>
ok
<palomer>
I find that parens are prettier for one liners while begin ... end is prettier if you span many lines
<hudini>
begin end
<hudini>
it sasys syntax error
<palomer>
paste it in a pastebin
<hudini>
if x > 10 then
<hudini>
is something wrong here ?
<hudini>
should it be if (x > 10) ?
<palomer>
nono
<hudini>
ok
<hudini>
im gona pastebin
<hudini>
nevermind
<hudini>
i found out whats wrong
<hudini>
nothing to do with my ifelse
* palomer
is off
bla has quit [Read error: 110 (Connection timed out)]
<christo_m>
hudini: you go to mac?
<christo_m>
Axle: it doenst need a height value, it uses front and back, and max_length btw
<Axle>
christ_m: yes, but your print code says that the queue does have a height value, which is wrong, and which is why the compiler chokes on the print function
<Axle>
christo_m:
threeve has quit []
bla has joined #ocaml
<christo_m>
Axle: (sigh)..thats example code for a stack
<christo_m>
im saying i have to implement somethign similar
<christo_m>
except the element record has the data field and the id field
<christo_m>
so a string and an int, as oppposed to just a string for the stack
<christo_m>
23:19 < christo_m> my friend, who isn't online, did it with a stacks implementation, except the element field only had a string, not a string and an int
<Axle>
christo_m: the code I posted there works, as long as you put Printf.printf instead of just printf
struktured__ has joined #ocaml
<hudini>
ok
<hudini>
another question
<hudini>
how do i do a let inside another let
<hudini>
for example
struktured__ is now known as struktured
<hudini>
let func1 p1 = let p1 = 4;;
<hudini>
so if i type func1 ab it will do let ab = 4;;
<hudini>
it says syntax error
<doy>
what are you trying to do
<hudini>
set a value to an array of my choice
<hudini>
or a record
<doy>
well, which
<hudini>
for example let func1 p1 = let p1 = { arg1 = "abc" ; arg2 = "def" };;
<hudini>
the above
<doy>
you either need to use references, like 'let func1 p1 = let p1 := { whatever }', or make the record fields mutable, and do something like 'let func1 p1 = p1.arg1 <- "abc"; p1.arg2 <- "def"'
<hudini>
hmm
<hudini>
so
<hudini>
let func1 p1 = p1.arg1 <- "abc" ; p2.arg2 <- "def" ;; the p2 record is initialized automatically ?
<thelema>
hudini: let bindings are local and immutable -- making a new binding just overrides the old one for the duration of its scope (usually to the end of the containing function)
<thelema>
they do not work the same as variable declarations.
<doy>
where did p2 come from
<thelema>
hudini: no, you need a valid record to pass in as p1.
<hudini>
what if i dont want to make the record mutable
<thelema>
then the best you can do is create a new record using the old one as a template.
<hudini>
ok
<hudini>
back to my example let func1 p1 = let p1 = { arg1 = "abc" ; arg2 = "def" };;
<hudini>
lol
<hudini>
how would i fix that syntax
<thelema>
what do you want func1 to do?
<hudini>
create a record named p1
<thelema>
return a record {arg1="abc"; arg2="def"}?
<hudini>
return nothing;
<palomer>
thelema, interested in running another test case?
<thelema>
Palace_Chan: for lablgtk? It's late and I should go to bed.
<hudini>
noo
<thelema>
grr, I should fix autocomplete so it favors the person who spoke last.
<Palace_Chan>
thelema, you can do that ?
<palomer>
for vanilla gtk
<palomer>
catch you tomorrow, then:P
<thelema>
hudini: it can create a record, but it can't affect the environment in the calling function.
<thelema>
such a capability would be... dangerous.
<hudini>
i dont understand the second part
<thelema>
palomer: yes, tomorrow.
<thelema>
Palace_Chan: no, I can't, but I'd like to.
<thelema>
Palace_Chan: maybe if I write an IRC client. how hard could it be? :)
<thelema>
hudini: the "dangerous" part, or "affect the environment" part?
<doy>
hudini: you can either use references/mutable things to modify what you're passing in, or you can return a completely new record
<hudini>
affect the environemnt
<hudini>
i just want funct1 to create a new record named p1 i dont want it to return anything
<palomer>
let's make an irc client in ocaml
<palomer>
ready, set, go!
<thelema>
when a line of code is running, it runs in an environment that has all the bound values and the values they're set to. You want a function to modify the environment of the caller.
<doy>
hudini: what do you mean by 'create a new record'
<doy>
where should it go?
<doy>
it has to go somewhere
<doy>
otherwise what's the point
<hudini>
it will be used
<hudini>
eventually
<hudini>
but for now its in p1
<hudini>
or its called p1
<thelema>
doy: I think the problem is that of namespaces / scope - different ones for each function.
<thelema>
hudini: there's not just one set of variable names for the entire program.
<thelema>
for example if I do:
<thelema>
let f x = x + 1 and let g x = 2 * x
<thelema>
those two functions refer to two different x values.
<hudini>
yea
<thelema>
if they were longer, I might use let to make a 'y' binding in both - these would be distinct.
<hudini>
so if i type func1 record it will create a new record called record
<thelema>
because they are in different scopes.
<Palace_Chan>
can i do something like: try let a = Hashtbl.find x in with Not_found -> etc..
<Palace_Chan>
it syntax errs me
<hudini>
i understand you but i dont think you understand me
<thelema>
ocaml doesn't allow that level of programming - camlp4 does, but that works on the syntax level.
<doy>
hudini: so you have a variable p1, and you want to call func1 p1
<doy>
and then have p1 be a record?
<thelema>
Palace_Chan: the [let a] binding only exists inside the try block.
<hudini>
doy: correct
<doy>
hudini: why not just do let p1 = func1 ()
<doy>
and have func1 return whatever you would be sticking in p1
<Palace_Chan>
guess i just have to make the try bigger and do the work within it then
<thelema>
Palace_Chan: you could do [let a = try Hashtbl.find x with Not_found -> value_for_a in
<hudini>
doy: what if i want the record to be named something other than p1
Linktim has quit [Read error: 110 (Connection timed out)]
Linktim_ has quit [Read error: 110 (Connection timed out)]
bering has quit ["Leaving"]
seafood has joined #ocaml
olgen has joined #ocaml
gim has joined #ocaml
Linktim has joined #ocaml
olgen has quit []
Linktim has quit [Read error: 110 (Connection timed out)]
seafood has quit []
middayc_ has joined #ocaml
middayc has quit [Read error: 110 (Connection timed out)]
Linktim has joined #ocaml
Camarade_Tux has quit [Read error: 110 (Connection timed out)]
Camarade_Tux has joined #ocaml
<Smerdyakov>
Anyone want to help me compare an ML-like web application language against competition like Rails and Django? I'm having trouble figuring out which applications to implement.
willb has joined #ocaml
<flux>
wiki, blog ;-)
<flux>
oh right, and social networking site..
middayc_ has quit []
<Smerdyakov>
A wiki is too much work for right now, because of text processing.
<Camarade_Tux>
minesweeper, bouler dash ? :D
<Smerdyakov>
No AJAX, either
<Smerdyakov>
Web 1.0 stuff
<Camarade_Tux>
it's getting so far away :p
<Camarade_Tux>
or, a shop, something like amazon/ebay ?
<flux>
chat site?
<Smerdyakov>
flux, probably can't be done nicely in Web 1.0 style.
<flux>
actually that needs ajax too
<flux>
and something like reddit is one application
<flux>
but many of these need some ajax for finishing touches
<flux>
I'm guessing you're planning to generate javascript in a type-safe fashion, but that can't be a trivial task :)
Linktim_ has joined #ocaml
Snark_ has joined #ocaml
Amorphous has quit [Read error: 110 (Connection timed out)]
Linktim has quit [Read error: 113 (No route to host)]
Amorphous has joined #ocaml
Linktim has joined #ocaml
Linktim_ has quit [Read error: 113 (No route to host)]
Linktim_ has joined #ocaml
Linktim has quit [Read error: 113 (No route to host)]
bering has joined #ocaml
Axle has joined #ocaml
<mfp>
Smerdyakov: the "pet store" app has often been used for those purposes (it became infamous when Microsoft rigged some benchmarks to claim that AST.NET was 20x faster than J2EE IIRC)
<Smerdyakov>
mfp, yeah, I looked at that a bit. Do you have a link to the Web 1.0 tutorial version of it?
<mfp>
I guess "hello world" does tell you something: if you're not getting several hundred/thousand reqs/sec, either you're doing it wrong or the lang/frameword is utter crap (PHP)
longh has joined #ocaml
<mfp>
*framework
<Smerdyakov>
I get 4000 requests per second when I redirect logging to /dev/null (testing with 1000 hits).
<Smerdyakov>
How does that compare with The State of the Art?
<Smerdyakov>
Oo, I just had a lucky ran of ab where every one of the 1000 requests was served within 2 ms. :)
<mfp>
don't know what is considered SOTA, but 4 Kreq/s sounds right; I got ~3.5 Kreq/s for lighttpd + trivial hello word through FastCGI some time ago
<xevz>
mfp: link_to has existed for a long time. :)
<mfp>
xevz: thought so, that petstore must be really old
<xevz>
Well, there's nothing forcing you to use link_to...
<xevz>
That URL doesn't look very Rails-like though. :P
<xevz>
Furthermore, what's unsafe with that line? Unless item is something that represents the address field, which is a bit unlikely...
<mfp>
hardcoded URI = breaks if you change your routing; didn't really mean unsafe but rather "fragile"
filp has quit ["Bye"]
<Camarade_Tux>
anybody think the "GENERATIVE blablabla" message on the caml-list is not spam ?
tomh has joined #ocaml
<Smerdyakov>
I can't seem to find the Java Pet Store 1.3.2 tarball to download from an official Sun site. :-(
mishok13 has quit [Read error: 110 (Connection timed out)]
<Smerdyakov>
That's the old version. I want 3.1.2.
<maxote>
mfp, Microsoft claimed that no enterprise can claim performance numbers using Microsoft products, now Microsoft claim performance numbers against J2EE of Sun/JRockit/...
<maxote>
Microsoft did the trap
<maxote>
I remember that the performance's improvement of M$ products is not an issue for M$
<maxote>
and now he claims that it's an issue
<fremo>
I'm looking for links or advices for writing lib's API...
alexyk has joined #ocaml
<alexyk>
can I use "function" to match more than one argument? this works:
<alexyk>
let x = function | (1,2) -> "a" | (2,3) -> "b" | _ -> "other";;
<alexyk>
this doesn't:
<alexyk>
let rec minlist = function | x::xs, m -> if m > x then minlist xs x else minlist xs m | _, m -> m;;
<alexyk>
no matter how I try to syntaxize after |
<alexyk>
| a b, or | (a,b)
<doy>
what are you trying to do
longh has quit [Read error: 104 (Connection reset by peer)]
<alexyk>
I just want to prettify my functions, instead of writing let f a b = match a b ... writing let f = function | a b -> ...
<alexyk>
so I wonder how "match" and "function" are different for subsequent pattern matching
<alexyk>
seems that function allows only a single thingy
<Smerdyakov>
That's right.
<doy>
yeah, i believe you'd have to use function twice
<doy>
that or make your function take a tuple rather than multiple arguments
code17 has quit [Remote closed the connection]
<alexyk>
ok... now I'm translating an F# prog into OCaml and it sucks that OCaml doesn't have a poolymorhic Set just like List
<alexyk>
F# has Set<'a> which is exactly like a List
code17 has joined #ocaml
<alexyk>
no need for stupid modules with redundant compare in them
<alexyk>
so I wonder is there a normal Set for OCaml somewhere?
<alexyk>
which I don't need to instantiate all the time for all kinds of things I want to keep unique?
* Smerdyakov
is glad that there are no polymorphic-compare data structures packages with OCaml.
<doy>
could fake it with Hashtbl maybe?
<Smerdyakov>
s/packages/packaged
<Smerdyakov>
Or maybe [Hashtbl] is a counterexample. Darn.
<doy>
i'd imagine the redundant compare is just because Set is implemented with binary trees
<alexyk>
doy, Smerdyakov: that's right, just doesn't feel like a Set
<doy>
same reason c++ maps require a compare function
<alexyk>
you can create ad hoc lists and should be able to have same Sets
<alexyk>
now when writing the darn compare's, I need to refer to int compare which is occluded
<alexyk>
how do I refer to the default compare for ints from my T.compare?
<Smerdyakov>
alexyk, no, because list operations are implemented parametrically. Set operations are type-dependent.
Linktim has joined #ocaml
<alexyk>
hmm -- is there a default compare op?
<alexyk>
I'm confused as I redefined compare for int*int
<alexyk>
now I can't get a default if it existed... or does it?
<alexyk>
Ruby's 1 <=> 2 gives -1, same for ints in OCaml -- is there a default one?
<doy>
not sure what you're asking
<alexyk>
is there a default function for integers which returns -1,0,1 depending on their comparison?
<doy>
compare
<doy>
?
paracetamolo has joined #ocaml
<alexyk>
right, now I redefined it for tuples and can't access the original
<Smerdyakov>
Pervasives.compare
<alexyk>
Smerdyakov: thank you! :)
<alexyk>
in the same vein: F# folk refers to :: as List.Cons, allowing to give it to things like fold
<alexyk>
can we refer to it in prefix notation?
<Smerdyakov>
No OCaml constructor may be treated as a function automatically.
<alexyk>
so I can't write fold with (::), have to say fun e l -> e::l :(
<alexyk>
let cons x xs = x::xs;; List.fold_right cons [1;2;3] [];;- : int list = [1; 2; 3]
<alexyk>
might as well have a List.Cons
<alexyk>
wouldn't hurt anybody...
<doy>
does seem sort of strange that it doesn't exist
<alexyk>
that's why I find F# refreshing -- Don Syme cleared up a few annoyances of OCaml
<alexyk>
just take // comment :)
Linktim_ has quit [Read error: 110 (Connection timed out)]
paracetamolo has left #ocaml []
Linktim has quit ["Quitte"]
alexyk has quit []
ygrek has joined #ocaml
blue_prawn has joined #ocaml
Snark_ has quit ["Ex-Chat"]
middayc has joined #ocaml
_zack has quit [Read error: 110 (Connection timed out)]
Linktim has joined #ocaml
<Camarade_Tux>
about obrowser, has anyone seen a way to benchmark it ? I'm under the impression it is much faster in webkit with the jit compiler enabled
Linktim has quit [Read error: 113 (No route to host)]
ulfdoz has joined #ocaml
<mfp>
Camarade_Tux: you could take programs from the shootout?
<Camarade_Tux>
mfp, right, good idea, I'll spend some time to set them up
<mfp>
the latest batch (x64 ubuntu Intel Q6600 quad-core) also has "JavaScript TraceMonkey" programs
Linktim has joined #ocaml
<mfp>
so the interpretative overhead can be measured
<mfp>
it's a matter of wrapping those standalone programs in some JS function to time them & write the results to the page, I guess
<Camarade_Tux>
I'll probably take a look at how sunspider does it
longh has joined #ocaml
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
<Camarade_Tux>
ok, I thought webkit with its jit was 30% slower than without on sunspider but was faster on obrowser, actually it's 40% *faster* on sunspider, that might explain why it's so much faster than yesterday (jit was broken until today)
vixey has joined #ocaml
jeddhaberstro has joined #ocaml
Linktim_ has joined #ocaml
Associat0r has joined #ocaml
Linktim has quit [Read error: 113 (No route to host)]
det has quit [Remote closed the connection]
yziquel has joined #ocaml
<yziquel>
hi. i want to compile an ocaml application of windows... with mingw. However, i have no clue at all at how to compile on windows. (I do not even know where to find the "command line"...) Any links or pointers?
* Camarade_Tux
wishes yziquel good luck
<yziquel>
yeah, thanks...
<yziquel>
it's a huge pain...
<Camarade_Tux>
yziquel, I think there is a README.win32 file at the root of the source (not sure of the name), you can read it
<doy>
yeah, following the readme got things working for me
<yziquel>
I'll look for it... <irony> what's "locate" on windows? </irony>
middayc has quit []
_JusSx_ has joined #ocaml
code17 has quit ["Leaving."]
ulfdoz has quit ["deprecated"]
ulfdoz has joined #ocaml
seafood has joined #ocaml
ygrek has quit [Remote closed the connection]
willb has quit [Read error: 60 (Operation timed out)]
m3ga has joined #ocaml
m3ga has quit [Read error: 54 (Connection reset by peer)]
det has joined #ocaml
det has quit [Remote closed the connection]
_JusSx_ has quit ["leaving"]
seafood has quit []
alexyk has joined #ocaml
seafood has joined #ocaml
hkBst has quit [Remote closed the connection]
Camarade_Tux is now known as Camarade_Tux|bed
GustNG has quit [Read error: 110 (Connection timed out)]
Linktim_ has quit [Read error: 104 (Connection reset by peer)]
Linktim has joined #ocaml
ulfdoz has quit [Read error: 113 (No route to host)]
<yziquel>
hi. sorry to be back again on this windows problem. I've read the README.win32 file, but i do not see in it any explanation on how to compile an ocaml application on windows using mingw... Do you guys just use cygwin to compile "as if" you were on a linux system? How do you get a native mingw+win32 application this way? I would like to have something i can run on another computer that has windows but not cygwin nor any other unix-like apps...
det has joined #ocaml
<doy>
yeah, you do it through cygwin, just using the mingw toolchain
det has quit [Client Quit]
det has joined #ocaml
det has quit [Read error: 54 (Connection reset by peer)]