ChanServ changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 4.00.1 http://bit.ly/UHeZyT | http://www.ocaml-lang.org
iago has quit [Quit: Leaving]
avsm has joined #ocaml
tbrady has quit [Quit: Leaving.]
ng_ has joined #ocaml
ng_ has quit [Client Quit]
emmanuelux has quit [Remote host closed the connection]
tac has quit [Quit: Page closed]
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
tbrady has joined #ocaml
GnomeStoleMyBike has quit [Ping timeout: 245 seconds]
tbrady has quit [Client Quit]
ontologiae has quit [Ping timeout: 245 seconds]
ulfdoz_ has joined #ocaml
<pippijn> is there something like __LINE__ in ocaml? (maybe in camlp4?)
ulfdoz has quit [Ping timeout: 255 seconds]
ulfdoz_ is now known as ulfdoz
arneis has quit [Ping timeout: 245 seconds]
Yoric has joined #ocaml
madroach has quit [Ping timeout: 244 seconds]
madroach has joined #ocaml
avsm has quit [Quit: Leaving.]
jamii has quit [Read error: Connection reset by peer]
avsm has joined #ocaml
tchell has quit [Ping timeout: 246 seconds]
mnabil has joined #ocaml
tane has quit [Quit: Verlassend]
avsm has quit [Quit: Leaving.]
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
TDJACR has quit [Read error: Connection reset by peer]
Neros has quit [Ping timeout: 240 seconds]
TDJACR has joined #ocaml
avsm has joined #ocaml
avsm has quit [Quit: Leaving.]
bzzbzz has quit [Quit: leaving]
mnabil has quit [Ping timeout: 245 seconds]
cdidd has joined #ocaml
mnabil has joined #ocaml
gnuvince has quit [Ping timeout: 245 seconds]
gnuvince has joined #ocaml
mjonsson has quit [Remote host closed the connection]
avsm has joined #ocaml
tac has joined #ocaml
answer_42 has joined #ocaml
UncleVasya has joined #ocaml
cdidd has quit [Remote host closed the connection]
avsm has quit [Quit: Leaving.]
mnabil has quit [Ping timeout: 245 seconds]
<pippijn> does batteries have something like String.unescaped?
<pippijn> I don't have ocaml 4, so I can't use Scanf.unescaped
mnabil has joined #ocaml
Cyanure has joined #ocaml
xavierm02 has joined #ocaml
mnabil has quit [Ping timeout: 245 seconds]
sivoais has quit [Ping timeout: 244 seconds]
sivoais has joined #ocaml
mnabil has joined #ocaml
tac has quit [Ping timeout: 245 seconds]
mnabil has quit [Ping timeout: 245 seconds]
Cyanure has quit [Remote host closed the connection]
cdidd has joined #ocaml
sepp2k has joined #ocaml
tane has joined #ocaml
Snark has joined #ocaml
answer_42 has quit [Ping timeout: 276 seconds]
GnomeStoleMyBike has joined #ocaml
Kakadu has joined #ocaml
arneis has joined #ocaml
arneis has quit [Ping timeout: 245 seconds]
tane has quit [Quit: Verlassend]
jewel has joined #ocaml
cdidd has quit [Remote host closed the connection]
sepp2k has quit [Ping timeout: 260 seconds]
fusillia has joined #ocaml
sepp2k has joined #ocaml
cdidd has joined #ocaml
fusillia has quit [Remote host closed the connection]
djcoin has joined #ocaml
ontologiae has joined #ocaml
djcoin has quit [Quit: WeeChat 0.3.9]
Neros_ has joined #ocaml
UncleVasya has quit []
emmanuelux has joined #ocaml
leoncamel has quit [Remote host closed the connection]
leoncamel has joined #ocaml
gmanson has joined #ocaml
gmanson has quit [Client Quit]
gmanson has joined #ocaml
gmanson has quit [Quit: irc2go]
Neros_ has quit [Remote host closed the connection]
Neros_ has joined #ocaml
UncleVasya has joined #ocaml
<UncleVasya> hi. If I want to do a shallow copy of a record with mutable fields, the simplest way is let ns = {state with table = state.table} ?
<mfp> UncleVasya: indeed, {x with foo = x.foo} for any field foo would do, regardless of the (non-)mutable nature of the fields
<UncleVasya> mfp: thanks. is this way of copying is common practice? I'm afraid it can be little unclear for the reader that this is just an exact copy.
<adrien> yes, it's common
mrm has joined #ocaml
Neros_ has quit [Remote host closed the connection]
Neros_ has joined #ocaml
Cyanure has joined #ocaml
Cyanure has quit [Remote host closed the connection]
ontologiae has quit [Ping timeout: 255 seconds]
iago has joined #ocaml
<Neros_> hello, is there a graphic interpreter for ocaml ? Because I find the console interpreter not very practical... Thank you :)
<adrien> how so not very practical?
ng_ has joined #ocaml
Simon___ has joined #ocaml
Cyanure has joined #ocaml
Simon___ has quit [Quit: Simon___]
jamii has joined #ocaml
ng_ has quit [Quit: Leaving]
<madroach> Neros_: try utop
<madroach> Neros_: or use something like rlwrap to provide line editing
<Neros_> ho thank you for rlwrap ! This is what i wanted :)
mnabil has joined #ocaml
wagle has joined #ocaml
NaCl_ has joined #ocaml
NaCl_ has quit [Changing host]
NaCl_ has joined #ocaml
Cyanure has quit [Remote host closed the connection]
BiDOrD_ has joined #ocaml
BiDOrD has quit [Ping timeout: 240 seconds]
mcclurmc_away has quit [Excess Flood]
mcclurmc has joined #ocaml
jathd has joined #ocaml
gnuvince has quit [Quit: Remember when men were men and regular expressions recognized regular languages?]
pango has quit [Ping timeout: 272 seconds]
UncleVasya has quit [Read error: Connection reset by peer]
pango has joined #ocaml
zzz_ has quit [Ping timeout: 245 seconds]
zzz_ has joined #ocaml
<flux> I wonder how much code/memory you need to evaluate ocaml bytecode
<flux> ..for the purposes of running them in the parallella minicores
<flux> probably not such a great idea.
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
mnabil has quit [Ping timeout: 260 seconds]
avsm has joined #ocaml
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
tane has joined #ocaml
tac has joined #ocaml
mrm has quit [Ping timeout: 245 seconds]
Drakken has quit [Ping timeout: 248 seconds]
joewilliams has quit [Remote host closed the connection]
Drakken has joined #ocaml
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
tane has quit [Quit: Verlassend]
tane has joined #ocaml
jewel has quit [Ping timeout: 276 seconds]
mrm has joined #ocaml
LowPotential has joined #ocaml
joewilliams has joined #ocaml
<LowPotential> Hi all. I have a ref variable, and I want to change its value based on a match with the result of a function (which needs to be decomposed to "get at" the value which needs to be checked). When I put the match expression in the middle of my function, O'Caml thinks it's the end of the function and complains. How get I take imperative actions inside the match expression and continue to do stuff afterwords?
<LowPotential> *"How can I take..."
<Kakadu> code plz
<LowPotential> Sure, just a second.
<LowPotential> Kakadu: Something like this https://gist.github.com/3965546
<LowPotential> Sorry, the comment should be "Should return 42." I wrote the example in a hurry.
<Kakadu> It doesn't?
<_habnabit> LowPotential, you need to wrap your entire match with parentheses or a begin-end
<Kakadu> aah
<_habnabit> LowPotential, the way this code is parsed, line 11 could be written | None -> (); !count
<tac> It looks like you could also inline the !count at the end inside the match statement
<tac> (in both branches)
<tac> actually, since you're setting count, then returning its value, you can just have the one branch as !count + x
<tac> and the other as just !count
<LowPotential> tac, _habnabit: It's a simplified example so the logic is not really the point. Can you clarify how I need to wrap the match? Is is "begin match ... with .. end"?
<_habnabit> LowPotential, yes
<_habnabit> LowPotential, with a ; after the end
<LowPotential> _habnabit: Aha! That did it. Thank you kindly.
avsm has quit [Quit: Leaving.]
sepp2k has quit [Ping timeout: 260 seconds]
answer_42 has joined #ocaml
Snark has quit [Quit: Quitte]
mrm has quit [Ping timeout: 260 seconds]
sepp2k has joined #ocaml
<wieczyk> wmeyer: Why people should use Lwt instead of Thread? Both are not real threads
<wieczyk> I see only one difference -- Thread module is preemptive.
jewel has joined #ocaml
<wieczyk> wmeyer: On latest Ocaml compiler source code I can see the 'otherlibs/systhreads' library.. where POSIX threads are used. Mhmhmh. some work for getting threads usable?
<wieczyk> I can see that ocamlruntime is not thread safe and have giant lock (global lock for runtime), like old operating system :D
Xizor has joined #ocaml
X1z0r has joined #ocaml
avsm has joined #ocaml
Xizor has quit [Ping timeout: 260 seconds]
LowPotential has quit [Ping timeout: 255 seconds]
wmeyer has quit [Ping timeout: 245 seconds]
<adrien> wieczyk: with native code, you get system threads
rwmjones has quit [Read error: Operation timed out]
<tac> I think I need to get some practice with functors. What's a good use case for using functors in Ocaml?
<thelema> tac: sets, where both an element type and the comparison function for those elements must be provided
<tac> thnx
rwmjones has joined #ocaml
avsm has quit [Quit: Leaving.]
<wieczyk> It would be nice to have two more syntax constructs in language:
<wieczyk> first for comparing values)
<wieczyk> compare a with
<wieczyk> | value1 -> ...
<wieczyk> | value2 -> ...
<wieczyk> | value3 -> ...
<wieczyk> bad syntax, sorry
<wieczyk> compare a with
<wieczyk> | expr1 -> ...
<wieczyk> | expr2 -> ...
<wieczyk> | expr3 -> ...
<_habnabit> how's that different from a match?
<thelema> like a match, but no destructuring, just equality comparison using some function?
<_habnabit> oh
<wieczyk> _habnabit: match is matching to pattern
<_habnabit> yes, I see it now
<wieczyk> thelema: yes
<wieczyk> compare a by f with
<wieczyk> | expr1 -> ...
<thelema> match a with x when x = expr1 -> ... | y when y = expr2 -> ...
<wieczyk> could be translated to
<wieczyk> Yes, it is one of possible translations.
<wieczyk> But the aim of language is to be practise for programmer, so I would like to have this in language.
<thelema> wieczyk: well, investigate bob zhang's syntax extension tools and make this
<wieczyk> I will check it.
<wieczyk> Second construction is similar, it is something similar to if .. elif ... else ..
avsm has joined #ocaml
<wieczyk> case
<wieczyk> | expr1 ->
<wieczyk> | expr2 ->
<wieczyk> ..
<wieczyk> if does
<wieczyk> if expr1 then ... else if expr2 then ... else ...
<wieczyk> it does*
avsm has quit [Client Quit]
<wieczyk> thelema: Could you give ma link for Bob zhang's se ?
<thelema> wieczyk: I imagine something more like f#'s activepatterns would be more likely to be included in ocaml
<flux> I just do match 0 with | _ when expr1 -> .. | _ when expr2 -> ..
<flux> in practice, I haven't found using sequences of expression evaluations often..
Xizor has joined #ocaml
<wieczyk> match is not good for this
<wieczyk> if you have some constant
<wieczyk> let my_constant = 42
<wieczyk> match n with | my_constant -> ...
<wieczyk> does not work
<wieczyk> you need to use 'when' which is ugly here.
<wieczyk> Thanks.
<flux> match 0 with _ when my_constant = z -> ..
<thelema> wieczyk: no, not that
<flux> wieczyk, perhaps a bit ugly, but is it really better to add a special new syntax for this?
<flux> I mean, then you find a new use case that's slightly different (well I need to do some bindings in the expr part..) that doesn't map this syntax well
<wieczyk> flux: yes, it is better.
<flux> and you have two similar but different syntaxes. to do a thing the other syntax does better you need to change everything in the expression.
X1z0r has quit [Ping timeout: 260 seconds]
<wieczyk> I do not understand, if you are comparing values then you are not speaking about binding anything.
<flux> well it's easy to say that when one is talking in the abstract about expr1 and expr2
<flux> but then you have the actual code you want to use it in
<flux> how often do you really compare a value to a fixed set of other variables?
<thelema> :( it looks like hongbo's work is gone...
<wieczyk> flux: I am not often coding in ML so I cannot answer.
<wieczyk> But comparing to values seems a reasonable thing for me, especially when I am doing it often in other languages.
<flux> wieczyk, well, maybe things are customarily done differently in ML?-)
<flux> I'm just grepping randomly my source codes for patterns that would fit case | expr1 -> .. | expr2 -> .. and I found one instance in a 2.2k line code: match Char.code str.[byte_at] with | x when x land 0b1110_0000 = 0b1100_0000 -> 2 | x when x land 0b1111_0000 = 0b1110_0000 -> 3 | x when x land 0b1111_1000 = 0b1111_0000 -> 4 | x -> 1
<flux> mind you, I used match and guard patterns probably dozens of times
<flux> and even when I use a guard, it often is done to the result of deconstructing some value
<flux> so then I need pattern matching..
jewel has quit [Read error: Operation timed out]
<wieczyk> Maybe you have right that comparing to value is unnecessary.
<wieczyk> Cannot you disagree with me that having my 'case' or 'elif' would be nice?
jbrown__ has quit [Read error: Operation timed out]
<flux> I would probably find use for 'elif' and it would be simple to support as well
<flux> although apparently in the same source I used 'else if' only twice
answer_42 has quit [Ping timeout: 276 seconds]
<flux> so perhaps adding a benefit of not writing 3 characters isn't worth breaking backwards compatibility
<flux> the ocaml compiler has 468 times 'else if'
<flux> but it has 250000 lines
<flux> so it uses twice as often 'else if' than my small program :)
<flux> it's more difficult to automatically analyze how often 'case' expression would be useful..
<wieczyk> I dont agree with any argument which is against 'elif'.
<flux> of course, it's an open question would people write their code differently should 'case' or 'elif' be available
<wieczyk> I am going to be crazy when I have small chaing of if then else if ...
<flux> wieczyk, so it's ok to introduce new syntactic elements that vary from previously existing 100% compatible replacements, even if it means the code can no longer be compiled with the previous version of the compiler?
<wieczyk> indentation is crazy there.
<adrien> fewer keywords is better
<flux> hmm, how does the indentation change? just imagine 'elif' == 'else if'
<wieczyk> OCaml 4.0 is not compatible which previous.
<flux> wieczyk, but this is such a mundane little detail
<wieczyk> The syntax for first-class modules is different.
<flux> I personally have never missed it
<adrien> List.assoc or (rev_)map are also nice for such tasks
<flux> also, it breaks old code should there exist code with variable name 'elif' :)
<flux> hey, it might exist, particularly on a program that's a compiler for language with the elif keyword..
<wieczyk> I totally dont agree with you, the elif is a basic construct. Allign old code for this change is also not problem, can be done by sed without problems.
<wieczyk> I could agree with you when I would speak about embedding more advanced constructs into language, which means breaking with simplicity.
<flux> wieczyk, but explain what other differences are there between 'elif' and 'else if' than the fact that the latter is three characters longer?
<wieczyk> But adding one simple keyword, available in other languages, is not a pain.
<wieczyk> [tab] if cond
<wieczyk> [tab][tab]then expr1
jbrown__ has joined #ocaml
<wieczyk> [tab][tab]else expr2
<wieczyk> is my style
<thelema> wieczyk: odd style
<flux> well, my style is that all those are with a single [tab]
<flux> should I wish to write 'then' and 'else' in the same line with the corresponding expr
<wieczyk> What means 'odd style'? (Sometime I cought my self on not understanding basic english)
<thelema> wieczyk: I think your style is odd or unusual
<wieczyk> I feel sad now.
<thelema> if cond then
<flux> I think most everyone, even in other languages, indent 'else' to the same depth as 'if'
<thelema> [tab] expr1
<thelema> else
<thelema> [tab] expr2
<wieczyk> With this style I would not need elif ;p
<wieczyk> but it is totally unusual for me to place condition and "then" in same line
<thelema> alternately:
<thelema> if cond
<thelema> then expr1
<thelema> else expr2
<flux> and then you can neatly align 'cond' to the level of expr1 and expr2 as well :-))
<wieczyk> OK, I will try to align my self to your style.
<flux> wieczyk, I think it's going to be a lot easier than getting the keyword 'elif' accepted into ocaml :)
<wieczyk> But at some day I will find a keyword you would also want to have ;p
<flux> maybe, maybe..
<wieczyk> btw: Do you known F#?
<flux> maybe something could be enhanced with the first class module support, it still seems a bit heavy to use..
<flux> I know of it, but I haven't written a single line of it
<wieczyk> I found good book related to this lang.
<wieczyk> "Real world functional programming"
<flux> and it interests me in the sense that if I wanted to do Windows development, it would be a highly interesting language
<wieczyk> by Microsoft.
<wieczyk> It is speaking about fp, comparing to design batterns.
<wieczyk> Seems to be good book for programmer, not only F# related.
<wieczyk> (I have run F# on mono today, works)
<wieczyk> but interpreter readline supports sucks a bit.
<wieczyk> Currently I have some projects in Ocaml
<wieczyk> one of those project is a SIP library
<wieczyk> SIP is a small protocol.
<wieczyk> There I would like to have comparing to values :D
<flux> I can see that that might be the case
<wieczyk> because I would like to be more interested to define return codes (like http return codes) by constants, not by algebraic data type
<wieczyk> becuase algebraic data types requires mapping between integers (from protocol) and representation.
<flux> but, I think you should use ADTs instead, even if there is mapping involved
<wieczyk> or, instead of nice comparing to values, I would like to have an enum.
<flux> it enables one to use the coverage checking of the compiler in match expressions
<wieczyk> enum would be an ADT without parameters, where I can tell which integer represents this vlue.
<wieczyk> Yes, ADTs are cool.
dwmw2_gone has quit [Ping timeout: 260 seconds]
Yoric has quit [Ping timeout: 246 seconds]
<wieczyk> But mapping between int and ADT seems to be unnecessary overhead.
<Qrntz> I wish OCaml supported ADTs with manually defined variant-integer mappings
<flux> and sometimes you might want to associate data with the return codes, no?
<flux> btw, here is one daring alternative that solves the matching problem as well..
<flux> use the C preprocessor for #define NUMBER 42 macros!
<flux> and everything works :)
<wieczyk> Ugly :D
<wieczyk> Less ugly, but still is
<wieczyk> let resp_404_not_found = 404
<wieczyk> and
<wieczyk> match code with
<wieczyk> | v when v == resp_404_not_found -> ...
<wieczyk> but it looks weird.
<flux> but I'm going to sleep
<flux> happy SIP hacking :)
<Qrntz> what I was speaking about is something like «type t = RNot_found (404) let f = function RNot_found -> …»
<flux> btw, you should read the blog entry on model-testing Arakoon (?) with ocaml
Kakadu has quit [Ping timeout: 246 seconds]
<flux> it sounds it could be releavnt to writing SIP implementation in ocaml
<Qrntz> at runtime, variants that do not reference another value are just integers so that's efficient, too
<wieczyk> flux: Could you give me a link?
<wieczyk> thnanks.
<wieczyk> thanks.
Submarine has quit [Quit: Leaving]
X1z0r has joined #ocaml
Xizor has quit [Ping timeout: 260 seconds]
cdidd has quit [Read error: Operation timed out]
dwmw2_gone has joined #ocaml
dwmw2_gone has quit [Client Quit]
dwmw2_gone has joined #ocaml
<wieczyk> OK
<wieczyk> It would be nice to have something like struct in C
<wieczyk> it differs from recors that.. name of fields are not global.
<wieczyk> I understand it complicated type inference... but now
dwmw2_gone has quit [Client Quit]
<wieczyk> first-class module complicated type inference... and F# has structs without record-field-names-hell
dwmw2_gone has joined #ocaml
dwmw2_gone has quit [Client Quit]
dwmw2_gone has joined #ocaml
<adrien> wieczyk: see ocaml svn
<adrien> and objects
sgnb has quit [Ping timeout: 245 seconds]
sgnb has joined #ocaml
<wieczyk> Why ocaml svn? What I could find there.
<wieczyk> Yes, objects, I forgot about this.
<adrien> Garrigue made something that uses context to differentiate between different record types
<adrien> that was a couple weeks ago
<wieczyk> Nice.
fusillia has joined #ocaml
Xizor has joined #ocaml
<tac> Global record fields are the bane of coders everywhere
X1z0r has quit [Ping timeout: 265 seconds]
gnuvince has joined #ocaml
<wieczyk> Can I access members of objects?
<wieczyk> without writing getter?
jave has joined #ocaml
<wieczyk> Hm, I can use 'method' instead of 'val'
<wieczyk> but I dont know if this is a pathology
<julm> wieczyk: only in an other class inheriting
uselpa has joined #ocaml
Yoric has joined #ocaml
uselpa has quit [Remote host closed the connection]
<wieczyk> OK
<wieczyk> next question
<wieczyk> method f = expr1
<wieczyk> expr1 is evaluated when object is constructed or each time method is called.
<wieczyk> ?
<wieczyk> Oh, I can check it by method f = raise Exit
<wieczyk> each time called ;/
dwmw2_gone has quit [Ping timeout: 260 seconds]
dwmw2_gone has joined #ocaml
jave has quit [Quit: ZNC - http://znc.in]
avsm has joined #ocaml
Yoric has quit [Ping timeout: 246 seconds]
avsm has quit [Client Quit]
X1z0r has joined #ocaml
Xizor has quit [Ping timeout: 260 seconds]
<wieczyk> Maybe it is possible to encode structs via first-class modules.
xavierm02 has quit [Quit: Leaving]
GnomeStoleMyBike has quit [Ping timeout: 252 seconds]
tac has quit [Quit: Page closed]
Progster has joined #ocaml
avsm has joined #ocaml
<wieczyk> [yes, it is possible]
mjonsson has joined #ocaml
avsm has quit [Client Quit]