dark_light changed the topic of #ocaml to: OCaml 3.09.2 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/
dibblego has joined #ocaml
meng has joined #ocaml
jeremy_c has joined #ocaml
fab_ has joined #ocaml
_fab has quit [Read error: 113 (No route to host)]
<jeremy_c> val fetch : result -> string option array option
<jeremy_c> that means the function returns Some an_array or None correct?
<jeremy_c> Then if Some an_array, then an_array is an array of string options? So an array element could be Some str or None ?
<dbueno_afk> Yes.
dbueno_afk is now known as dbueno
<jeremy_c> dbueno: I think I am learning to read some of these finally :-)
<dbueno> They can get hard to parse. =]
<jeremy_c> How can I make val mutable id = 0 be an int64 instead of plain int?
jcreigh has joined #ocaml
meng has quit []
<jeremy_c> nm. my problem w/syntax was in another location.
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
mikeX has quit ["leaving"]
ramkrsna has quit [Read error: 110 (Connection timed out)]
pango has quit [Remote closed the connection]
jcreigh has joined #ocaml
<jeremy_c> Line 11, I am getting a syntax error on compile. Anyone see anything wrong with it?
<jeremy_c> It's eluding me.
<jeremy_c> nm. missing "in" on line 10... duh.
Wild_Cat has joined #ocaml
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
Wild_Cat has quit []
b00t has joined #ocaml
Ballin_105 has joined #ocaml
levi_home has joined #ocaml
ramkrsna has joined #ocaml
<Ballin_105> lets say i have 1 fie for functions and another file calling them spilitting it up
<Ballin_105> how can i unclude the file
<Ballin_105> Include
pango has joined #ocaml
<Ballin_105> pango: how can i include other files into another file ........like my functions.ml into my main.ml ?
_velco has joined #ocaml
<jeremy_c> Ballin_105: ocamlc file1.ml file2.ml
<jeremy_c> Ballin_105: then, in file2, say you want to access, file1's abc function
<jeremy_c> Ballin_105: file1.say_hello_to "Ballin_105"
<Ballin_105> what ?
<Ballin_105> wtf
<jeremy_c> hold on, better example.
<Ballin_105> can i jus add like open file1 or somethingwhere i dont havbe to specify for every function
<jeremy_c> there.
<jeremy_c> arg.
<jeremy_c> that example is wrong.
<jeremy_c> there, that one is right, sorry about that.
<Ballin_105> can i just open the file
<jeremy_c> yes.
<Ballin_105> open greater.ml
<jeremy_c> like that.
<jeremy_c> don't spec the .ml ... also, it's capitalized.
<jeremy_c> on the open statement that is.
<jeremy_c> if you have file abc.ml, in other files you should open Abc
<jeremy_c> abc_def.ml you should open Abc_def
<Ballin_105> ahhhhh
<Ballin_105> thanks :)
<Ballin_105> jeremy_c: ^^
<jeremy_c> np. I'm a newbie too and it confused me trying to figure it all out.
<jeremy_c> Ballin_105: beware. If def.ml depends on abc.ml, abc.ml must appear on the compile line before def.ml ... ocamlc abc.ml def.ml will work. ocamlc def.ml abc.ml will not.
<jeremy_c> Ballin_105: for that reason, I don't think it's possible to have a two files that include each other. like abc.ml needing def.ml and def.ml needing abc.ml ... that will not work.
dark_light has joined #ocaml
<Ballin_105> who would do that lol
<jeremy_c> Ballin_105: alot of other languages allow it.
<Ballin_105> well i dont program in that fashion
<jeremy_c> good
<Ballin_105> im getting alot better in ocaml
<Ballin_105> just my file was getting mighty huge :P
<Ballin_105> is it better / bestter performance wise to use prefix's or is it ok to use open as well with no difference
<jeremy_c> Ballin_105: I don't know. If my file has a lot of internal functions and I only use one or two from it, then I just prefix.
<jeremy_c> Ballin_105: I am not sure what happens if abc.ml has a say_hello function and your def.ml has a say_hello method as well, if you open say def in abc... I would assume some undesired side effects would occur.
<Ballin_105> i am just eondering if it better perfroamnce wise to prefix
<jeremy_c> Ballin_105: I can't answer that, don't know.
Snark has joined #ocaml
rillig has joined #ocaml
jeremy_c has quit [Client Quit]
b00t has quit [Remote closed the connection]
f78 has quit ["Leaving"]
<Ballin_105> hmmmmm
<Ballin_105> thats not exactly working here
<Ballin_105> is Global any kind of Ocaml module
b00t has joined #ocaml
shawn has joined #ocaml
<pango> Ballin_105:it doesn't change anything on generated program
<pango> (the use of open vs. prefixing each identifier explicitly)
_JusSx_ has joined #ocaml
love-pingoo has joined #ocaml
shawn has quit [Connection timed out]
dibblego has quit [Remote closed the connection]
<Ballin_105> open Mytcpstuff
<Ballin_105> is not working
<Ballin_105> doesnt exactly open the file hmmmmmm
<pango> open just does namespace changes, loading or linking files is a different matter
<flux__> ballin_105, does the open fail?
<flux__> one "traditional" mistakke is to define module Foo in file foo.ml
<flux__> wgich then needs to be referred as Foo.FOo, because all modules implicitly create a new module, using their name
Wild_Cat has joined #ocaml
ramki has joined #ocaml
ramkrsna has quit [Read error: 110 (Connection timed out)]
Leonidas has joined #ocaml
love-pingoo has quit ["Leaving"]
jeremy_c has joined #ocaml
Wild_Cat has quit []
Wild_Cat has joined #ocaml
ruben17 has joined #ocaml
_JusSx_ has quit ["leaving"]
slipstream-- has joined #ocaml
ruben17 has left #ocaml []
slipstream has quit [Read error: 110 (Connection timed out)]
Snark has quit ["Leaving"]
<jeremy_c> Is there a way I can load a file in ocaml then go to the top interface?
<pango> the top interface is the bytecode compiler with a small interactive layer on top
<pango> you can use #use "file.ml" to interpret an file, or #load "file.cmo" to load an already byte-compiled module
<pango> or start ocaml file.cmo to load it upon start
smimou has joined #ocaml
<pango> or ocamlmktop -o newtop file.cmo to create a new toplevel enhanced with your module
<pango> last one for completeness, you can put ocaml code and toplevel pragmas in ~/.ocamlinit, and they'll be interpreted each time ocaml is started
_JusSx_ has joined #ocaml
<jeremy_c> pango: I am trying to use Str for regexp matching. let re = regexp "<\\(.*\\)>" ;; matches just about the entire HTML doc. However, "<title>\\(.*\\)</title>" does not match anything, but clearly in the file it has <title>John Doe</title> ... do you know what I am doing wrong?
<jeremy_c> arg. even "title\\(.*\\)title" does not match.
<jeremy_c> hm, something weird in my file. if I set a string to <title>hello</title> matches = hello. will go back to work to figure it out.
<jeremy_c> Ok, has to do with newlines. How can I match across newlines?
<flux__> maybe it has an option. (maybe not, though..) I suggest you take a look at pcre-ocaml-module - perl regular expressions
<flux__> they have both greedy and non-greedy matches, where non-greedy is what you want
<flux__> and I think it has options for hanlding newlines in atleast two different ways
<jeremy_c> flux__: thanks.
<flux__> btw, STr-module is not thread-safe either, which can be surprising at some point.. (and its thread-nonsafety isn't limited to its non-thread-safe interface either)
<pango> jeremy_c: the <title>\\(.*\\)</title> case seems to work for me, maybe you tried Str.string_match (which is left anchored) instead of Str.search_forward ?
<jeremy_c> pango: yes, I used string_match. But I want to match across lines.
<pango> (other than that, I agree with flux__ about Str module limitations)
<jeremy_c> title was just a test after I could not make my first desire work.
<pango> I guess the problem is '.' that matches anything but newlines...
<jeremy_c> Can you tell me how to do ungreedy matches? I am matching again, one line just fine with Pcre.
<pango> .*?
<jeremy_c> so, ".*?" should match the entire file, right?
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
<pango> in backtracking algorithm, it should first try the smallest string that matches, instead of the longest string that matches
<jeremy_c> that raises Not_found
<dark_light> how can i resolv a address in ocaml? like: resolv "irc.freenode.org", returning a Unix.inet_addr as reply
<dark_light> oopps, i think i found. gethostbyname?
<pango> dark_light: yes
<dark_light> its more complet i though, i was really looking only for a IP.. but, a host can point to another host, or a couple of ips.. i.. think..
<pango> dark_light: DNS can return more than one IP... that's why you get an inet_addr array
<dark_light> pango, i should select one at random? or select the first?
<pango> up to you
<dark_light> the array will be randomized when it was passed to me?
<dark_light> maybe i should try one, then the second..
<pango> not in my experience
<dark_light> hmm.. ok
asmith has joined #ocaml
<flux__> dark_light, it will be ordered in an undetermined fashion
<flux__> usually consecutive requests will return the answers in a different order
<dark_light> flux__, nice
<flux__> (I think the result is just cycled, though)
<pango> flux__: not in my experience
<flux__> anyway, no need to worry about that. yes, it@s nice, peolpe behind dns were smart ;)
<flux__> pango, not what?
<pango> flux__: but it may depend on external factors, like recursive servers caching results ?
<pango> flux__: not cycled
<pango> mmmh thinking of it, that was in an application that did its own caching too...
<dark_light> i have a design problem.. i have two functions: one to create a connection to a irc server, and another to actually connect.. i should resolv the server name during creation or connection?
<flux__> may be. I'm guessing either result is standards compliant
<dark_light> if i resolv during creation, i will have two blocks.. but if i resolv at connection, maybe some tasks will be more difficult or error-attracting..
<flux__> do you expect to create connections you won't actually connect?
<pango> depends whether it will be ok to restart your application the day the server changes of IP ;)
<dark_light> flux__, no, but.. but..
<dark_light> pango, !!
<flux__> pango's got a point
<flux__> if you reconnect, you should atleast alternate ip's of the dns record
<dark_light> flux__, i like to.. separate different tasks..
<dark_light> flux__, you recommend that i connect in creation?
<dark_light> because i can.. disconnect.. and then reconnect..
<dark_light> i will have a "connect" function anyway
<pango> I don't think solving name just before connection will add so much complexity, if at all
<dark_light> ok, i will have two functions.. createdummyserver, that creates a.. dummy server, and createserver, that create and then connect..
<dark_light> pango, but if my function to create a server didn't resolv the names, i would end with a odd record that isn't properly filled
<flux__> dark_light, create_connection : ? resolve : [ Immediate | Connect ] .. ;-)
<dark_light> errr.. and then i use this with create_connection resolve=Immediate something ..? well..
<dark_light> it's somehow odd.....
Wild_Cat has quit []
nattfodd has quit [Remote closed the connection]
nattfodd has joined #ocaml
slipstream has joined #ocaml
<flux__> dark_light, you haven't used optional arguments?
<flux__> or labeled
<dark_light> no.. some functions has it on the official libraty, but i avoid them and i am happy with this :)
<flux__> they are fun, check them out ;)
<dark_light> but.. i think it's better a.. create_connection ?auto_connect : ..., because makes more sense i autoconnect or not..
<dark_light> and if i don't autoconnect, i will force a resolv.. for not making a inconsistent environment..
slipstream-- has quit [Read error: 104 (Connection reset by peer)]
<flux__> well.. just try not to overcomplicate it. choose something that can later be changed without breaking everything..
<dark_light> can i declare that variant type in the definition of the function? let x = (A : [A | B]), this | is a syntax error.. :(
<dark_light> flux__, hmm.. yes
<flux__> you can use those variants (with backtics)
<flux__> otherwise, no
<dark_light> flux__, i though in use OO.. but if i want to extend a OO, i must create a new class, and that isn't very useful for creating dynamic functions (and mixing methods and functions isn't very cool)
<flux__> I actually don't thinkg mixing oo and free functions would be bad
<flux__> infact even advisable in order to maje the class have a minimal interface
<dark_light> sometimes i will have a confusion: "this belongs to class or belongs to a function?"
<dark_light> flux__, you made me thinking again in using OO.. :(
<dark_light> design is too complicated.. now i understand the folks that study apparently useless stuff like software enginnering :(
<dark_light> flux__, what you think, wrote all again with OO or stay with i have? :(
<dark_light> i have only 20 lines of code
<dark_light> write*..
<pango> I think you should first group fields based on _when_ they are available
<pango> maybe informations that are only available (and useful) when a connection is opened should go in a different record/object/whatever
<pango> then main record gets a mutable connection : connection_info option, for example
<pango> or maybe you'll discover that the whole record is useless if a connection cannot be established, and your create_server function raises an exception when it happens; Up to the upper layers to handle case when no server is available ;)
<dark_light> pango, so you would prefer to stay with functions and don't go to OO?
<pango> never used ocaml's OO
<dark_light> so a record is just fine?
f78 has joined #ocaml
<dark_light> pango, i decided to don't use OO when saw a lisp library that do the same with normal functions..
<pango> there's more than one way to do it, depending on how large and modular you want to go
<pango> 'servers' could be an abstract type in a module, and then implementation doesn't matter outside of this module, for example
<dark_light> design IS complicated..
<dark_light> but is the funnier part!
<dark_light> pango, i just wanted a bot that has a database.. and i can add things with "something is something2".. :( :(
<dark_light> just like many others:)
yacstud has joined #ocaml
<pango> Looks like a "thousand to few thousands of lines" project then
<pango> writing such modules may not be absolutely required for those, and it's extra work... On the other hand, it could be a useful experience; and -why not- even productive if some of the modules are reusable :)
<pango> on that point, it's no different than writing reusable classes ;)
<dark_light> pango, i have absolutely nothing to do, and i am angry because i don't know what to do to obtain goron's bracelet in zelda - ocarina of time.. and i have never writed a useful module
<dark_light> i am including commenting in english, and setting all names in english.. a thing that usually i don't do
<dark_light> (comparing ocaml to zelda, this guy must be a child! :PP)
<pango> only finished Secret of Mana, so I can't help ;)
<dark_light> ahahahahah
<dark_light> ok, i decided that OO is more high level, so this actually will be my first real OO project..
<dark_light> (a couple of records to store just a connection isn't very nice :()
_ziggurat has joined #ocaml
ziggurat has quit [Success]
pango has quit [Remote closed the connection]
pango_ has joined #ocaml
<pango_> Tor wrath ;)
pango_ has quit [Client Quit]
pango has joined #ocaml
<dark_light> pango, wow, rlz
<dark_light> o'reilly seems to be the nerd press
Snark has joined #ocaml
yacstud has quit []
shawn has joined #ocaml
_velco has quit ["I'm outta here ..."]
<flux__> dark_light, from a practical point of view: with records in other modules you need to refer to their fields with foo.Module.field, while with oo it works like foo#method
<flux__> also, with records you may use pattern matching
<flux__> so.. ;)
<flux__> but, if you don't see OO bringing any advantages, why bother going there..
<dark_light> i am a man of the church of OO right now
<flux__> well, try OO and see how it fits
<flux__> it might be just great
<flux__> ;)
<flux__> but I'm going off to sleep
<flux__> happy hacking..
<dark_light> (at moment i don't begun the first 2 lines of program..)
<dark_light> flux__, thanks! bye..:)
Snark has quit ["Leaving"]
Wild_Cat has joined #ocaml
Wild_Cat has quit []
fab_ has quit []
clog_ has joined #ocaml
smimou has quit ["bli"]
clog has quit [Connection timed out]
clog_ is now known as clog
_JusSx_ has quit ["leaving"]
_ziggurat_ has joined #ocaml
_ziggurat has quit [Read error: 110 (Connection timed out)]
rillig has quit ["exit(EXIT_SUCCESS)"]