smimou changed the topic of #ocaml to: OCaml 3.08.3 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
smimou has quit ["?"]
cdutchyn has joined #ocaml
vezenchio has quit ["\o/ in mochintin namocniuh \o/"]
dan2 has quit ["Leaving"]
dan2 has joined #ocaml
dan2 is now known as dan2_
dan2_ is now known as dan2
Gueben has quit [Read error: 104 (Connection reset by peer)]
fab_ has joined #ocaml
_fab has quit [Read error: 110 (Connection timed out)]
interfer` has joined #ocaml
interfer` has quit [Remote closed the connection]
Smerdyakov has joined #ocaml
Anarchos has joined #ocaml
<Anarchos> bonjour tout le monde
Anarchos has left #ocaml []
Anarchos has joined #ocaml
<Anarchos> rebonjour
<Anarchos> does anyone know why the ocaml team is currently changing the signal management ?
Enveigler has joined #ocaml
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
Smerdyakov has quit []
Snark has joined #ocaml
<zvrba> is there any rationale why some data structures are mutable (e.g. queue) and some functional (e.g. map) in the standard library?
<zvrba> ..I mean some design document on the web
<zvrba> I'm just wondering
<shrimpx> i've wondered about that myself; i think it just came down to performance/usability tradeoffs
<shrimpx> ocaml folks don't seem to be too concerned with the whole "let's make everything functional" thing
Enveigler_ has joined #ocaml
<zvrba> that's nice that it's not pure functional. imho gives a smoother transition to programmers coming from procedural background
<zvrba> what I *do* like is interface consistency though.. functional update of the queue is O(n) and functional update of balanced tree is O(log n)
<zvrba> so it might be performance-related reason
<zvrba> as you've said
<zvrba> I'm wondering.. how does one do numerical calculations in pure functional languages like Haskell?
<zvrba> e.g. given an array of 1000x1000 floats, you'd have to make a copy to change a single value
<zvrba> and relatively simple calculation like Gaussian elimination has O(n^3) updates
<zvrba> *note* I'm not starting a flame war :) i'm just curious
<Enveigler_> try asking in #haskell
<zvrba> ok
Enveigler has quit [Read error: 110 (Connection timed out)]
Nutssh has joined #ocaml
<Enveigler_> zvrba: That's pretty typical of #haskell. You rarely get a straight answer to a question. Just a lot of theoretical ifs, buts, and maybes :(
Nutssh has quit [Client Quit]
<zvrba> Enveigler_: that is also my general feeling. whenever you ask about side-effects you get a 'monad' in the answer :)
<zvrba> ahh.. have to go. bbl.
* Enveigler_ nods. I don't mind the term "monad", but it would help if there were some non-trivial examples of solving problems using them. From my perspective Ocaml's pragmatic mix of pure functional and imperative is not just easier to grasp, but is a better fit to real worlld problems.
whee has quit ["Leaving"]
<tnay|zzz> monads .. there will be no gnu version of it :-)
tnay|zzz is now known as tny
<shrimpx> heh
<fluxx> the shell does sound interesting though. too bad the shell development in the unix world has stagnated ;)
smimou has joined #ocaml
fab_ has quit []
Enveigler has joined #ocaml
Enveigler_ has quit [Read error: 110 (Connection timed out)]
Enveigler_ has joined #ocaml
oracle1 has joined #ocaml
Enveigler has quit [Read error: 110 (Connection timed out)]
Boojum has joined #ocaml
Snark has quit [Read error: 110 (Connection timed out)]
_JusSx_ has joined #ocaml
Enveigler_ has quit [Read error: 110 (Connection timed out)]
Boojum is now known as Snark
Saulzar has joined #ocaml
vezenchio has joined #ocaml
<ulfdoz> re
<Number17> are underscores consitered the best practice for names in ocaml? or is lowerCamelCase consitered to be fine as well (I know lisp people get emotional about this)
<pnou_> the best practice
<smimou> underscores are the de facto standard
<pnou_> is underscore
<Number17> alright; I'll code with underscores then
<vezenchio> incidentally, what about constructors? are they supposed to be used LIKE_THIS, or Like_this or LikeThis ?
<smimou> Like_this
<Snark> constructors?
<smimou> type constructors I guess
<ulfdoz> Where can I get ocaml{yacc,lex}?
<smimou> they come with ocaml
<vezenchio> they are included in the standard distribution=?
<ulfdoz> smimou: thx, and sorry, I just read in the tutorial. :)
__DL__ has joined #ocaml
whee has joined #ocaml
Smerdyakov has joined #ocaml
<ulfdoz> I try to match the begin of a line in ocamllex, but it it complains about the line "let begin_of_line = ^" with "File "mc_lexer.mll", line 21, character 20: syntax error.
<ulfdoz> character 20 is end of line, so I suppose it complains about the "^". But why?
<Smerdyakov> ^ is an infix operator..
<Smerdyakov> It's never legal to have it immediately following =.
<ulfdoz> Ok, I double quoted, so it is a string now, hopefully it keeps the semantic.
<Number17> o'caml's type system is really nice :)
<Smerdyakov> Number17, is your name Kroby?
<Number17> In real life? No
<Smerdyakov> OK. Nick stealer. ;P
<ulfdoz> Who's that?
<Smerdyakov> Someone I knew on EFNet in the late 90's.
<Number17> ok, I'll change it then
<Smerdyakov> Number17, it's OK. I haven't seen him in many years! :D
Number17 is now known as Revision17
<Revision17> bah, I think I registered this nick a year ago and forgot the password
<Revision17> oh, nope I remembered it
<Revision17> the only reason I was "Number17" is on another IRC server I go bye that, and I was too lazy to configure my client to use Revision17 here
<Revision17> bye -> by
<ulfdoz> Nice, until now I play around with ocamllex and yacc for 4h and even forgot to smoke. All that only, because I can't find the syntax error in my sendmail.mc. :)
<Smerdyakov> If they make you forget to smoke, then they've earned their status as useful!
* Revision17 suggests you play around for another 68 hours
<ulfdoz> I like smoking, although it starts to get too expensive, at least in Germany.
<Smerdyakov> ulfdoz, it gets expensive for your health anywhere.
<Revision17> I know people who love it. It's just the $$$ and the health damages that bother me
<Revision17> though smoking pipe tobacco once a week or so I see no issue with
<ulfdoz> Smerdyakov: I know, but we'll all die, some earlier the other shortly afterwards.
<Smerdyakov> Revision17, oh, so it's just the dying that bothers you? No biggie.
<Revision17> Smerdyakov: pretty much; I already inhale enough dust, asbestos, and plastic fumes at work that I don't want to speed up the process
<Smerdyakov> Revision17, then you should get a new job.
<Smerdyakov> Revision17, my biggest risk is inhaling coffee fumes.
<Revision17> after 5 years of working at it; I'm quitting at the end of the month
<Smerdyakov> So you're one of those rare people here without a math/science/engineering job?
<Revision17> I work miscellaneous jobs for a construction company
<Revision17> going back to college in september full time to try and finish my Information Systems + Computer Engineering undergrad
Enveigler_ has joined #ocaml
Enveigler_ has quit [Read error: 110 (Connection timed out)]
r2d4 has joined #ocaml
<r2d4> how do I read a file by lines?
<r2d4> any high level IO library?
<Smerdyakov> You should fine the requires support in Pervasives, the module that is opened by default.
<Smerdyakov> s/requires/required
<r2d4> OK! Thanks. It works.
Tachyon76 has joined #ocaml
skylan has quit [Connection timed out]
Tachyon76 has quit ["Leaving"]
__DL__ has quit [Remote closed the connection]
__DL__ has joined #ocaml
__DL__ has quit [Remote closed the connection]
Snark has left #ocaml []
<Revision17> would there be any way I could get a value from a function being called by Hashtbl.iter without using a side effect (like a reference)? (iter : ('a -> 'b -> unit) -> ('a, 'b) t -> unit)
<Smerdyakov> That's provably impossible, since the return type is unit.
<Smerdyakov> You should use Hashtbl.fold instead for that.
mikeX has joined #ocaml
<zvrba> how does Queue.iter prevent queue being changed while iterated?
<zvrba> does it make a copy?
<r2d4> can I check for the type of a value at runtime in polymorphic functions?
<r2d4> like type(x) in Python
<Smerdyakov> r2d4, no.
<zvrba> r2d4: i don't think so. I've asked something similar to that few days ago
<Smerdyakov> r2d4, that information is not preserved through compilation.
<zvrba> and the answer was that it would lead to function overloading
<zvrba> which is not available
<r2d4> OK! I am trying to make a function that handles different Lists.
<zvrba> in what way different?
<Smerdyakov> "Lists" with a capital "L" is not something in the OCaml standard library.
<r2d4> Is it possible to match a variable for it's type. Guess it's the same question.
<r2d4> [1;2;3]
<zvrba> this is a int list
<Smerdyakov> r2d4, not possible. There is NO type information available about anything when the program runs.
<Smerdyakov> You must get out of the dynamic typing mindset and get used to statically parameterized code, via functors or passing function arguments.
<Smerdyakov> Passing handler functions as arguments is more dynamic, but you must still plan ahead of time and pass those functions.
<r2d4> Thanks. Just what I did now. :-)
<r2d4> I have mainly used Python for the last 3-4 years and Delphi with RTTI before that. Hard to get out of it in a hurry :-)
<r2d4> In Python, I build lists in code adding elements along the way and finally doing something with it. How do I do that in OCaml (unless there is a better way). I only see functions to add a list to a list and that seems to create a new list(correct me if I am wrong). Is there a linked list like data structure?
<Smerdyakov> The built-in list type is immutable.
<Smerdyakov> There are very few mutable types included with OCaml.
<Smerdyakov> The only ones that come to mind are the primitives, ref and array; and the types in Hashtbl, Queue, and Stack.
<Smerdyakov> But, again, this is not a problem. You are simply thinking about this imperatively.
<Smerdyakov> It is generally a sign of bad planning if you need to use a loop or recursive function in OCaml.
<Smerdyakov> You can do most everything with higher-order functions, instead of ad-hoc looping and imperative update.
<r2d4> I do plan to map a function at the end.
<r2d4> but I am still building a list prior (unless there is a better way).
<Smerdyakov> How are you "building" it?
<r2d4> Right now? List.append
<Smerdyakov> No, I am asking about what high-level algorithm you are using to construct the list.
<r2d4> OK! I get your point.
<r2d4> That is a loop.
<Smerdyakov> It's not just a point. If you tell me the algorithm, I can tell you how I'd code it.
<r2d4> I use readlines on a file object in Python a lot. Since I did not see that in Ocaml, I was trying to build one as an exercize. I am trying to create a list of lines from a file and return it. A better way is to return an iterator but I did not get to that part in Ocaml.
threeve has joined #ocaml
<Smerdyakov> OK. You should probably be using the :: constructor for each line you read, prepending it to the list of lines already read.
<Smerdyakov> Then reverse the list at the end.
<Smerdyakov> What you said about "returning an iterator" is also preferable if possible, though in OCaml, "iterators" become higher-order functions like Hashtbl.iter.
<r2d4> That's what I was doing but doesn't that create a new list at each element addition?
<Smerdyakov> (This is much more generalize, since it allows many more patterns than Python iterators do.)
<Smerdyakov> Lists are immutable. There is no way to "change" them, period.
<Smerdyakov> Perhaps you are assuming the wrong performance characteristics of ::?
<r2d4> I understand. So what would be the preferable, reasonably efficient way to use instead?
<r2d4> I don't need to use the built in list type.
<Smerdyakov> If you really want to build an output list, then :: each new line onto the beginning of an accumulator as you go, then reverse the final result.
<Smerdyakov> This is not "inefficient."
<Smerdyakov> All constructor applications, :: included, run in constant time.
<r2d4> A linked list elements simply contain a pointer to the next element. So each addition should only allocate the element sized memory. But a new list each time should allocate progressively larger memory which I presumed was more expensive.
<Smerdyakov> No, you have the wrong idea of what "a new list" is.
<Smerdyakov> First, when talking about functional programs, it is never helpful to think about "a new object."
<Smerdyakov> Any more than when you write 1+1, you wonder "is the second 1 a new 1?".
<Smerdyakov> ML compilers will tend to be implemented such that no primitive operation takes more than constant time.
<Smerdyakov> It can be interesting to know how they achieve this, but it's really irrelevant to the developer in almost all cases.
<Smerdyakov> So how :: is implemented isn't important.
<Smerdyakov> However, in case you care, all it does is allocate a new cell, write the data bit into its data field, write the next pointer into its next field, and return the address of this new cell.
<r2d4> OK! I think I understand.
mikeX has quit ["Leaving"]
r2d4 has quit ["Chatzilla 0.9.68a [Firefox 1.0.4/20050511]"]
Sonarman has quit [Read error: 110 (Connection timed out)]
tny has quit []
smimou has quit ["?"]
ulfdoz_ has joined #ocaml
_JusSx_ has quit ["leaving"]
ulfdoz has quit [Read error: 110 (Connection timed out)]