flux__ 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/
rillig has quit ["exit(EXIT_SUCCESS)"]
khaladan has quit [Read error: 104 (Connection reset by peer)]
chessguy has joined #ocaml
chessguy has quit [" Try HydraIRC -> http://www.hydrairc.com <-"]
jcreigh has joined #ocaml
jcreigh has quit ["Do androids dream of electric sheep?"]
ramkrsna has joined #ocaml
Smerdyakov has quit ["Leaving"]
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
Submarine has quit [Read error: 113 (No route to host)]
Skal has joined #ocaml
Submarine has joined #ocaml
pango is now known as pangoafk
zedrdave has joined #ocaml
<zedrdave> good morning...
<zedrdave> I have sort of a silly question, but no amount of googling managed to get me the answer...
<zedrdave> I'm trying to have a simple ocaml script output shown in the terminal...
<zedrdave> basically the way it would if I was to start interactive mode and #use "this_file.ml"...
<zedrdave> is there an option to the 'ocaml' command that would do that?
<zedrdave> (obviously I checked the doc and didn't see any)
pangoafk is now known as pango
<pango> zedrdave: I'm not sure I understand the question...
<zedrdave> pango: well... right now I have a small .ml script...
<zedrdave> since I use my own editor, I'd like an easy way (preferably a single command line) to run the file and get its ocaml output to the terminal...
<zedrdave> currently, if I do $ocaml my_file.ml
<zedrdave> I only get syntax errors if any... no output...
<zedrdave> of course, if I run the interactive shell then loads the file, it works... but this is a bit of a pain...
<pango> and what did you expect to be displayed ?
<pango> the expressions, before they're being evaluated ?
<zedrdave> exactly the same as what the interactive shell does, line-by-line evaluation...
<zedrdave> I don't really "expect" it to... I realize it's normal behaviour not to... just wondering if there was a verbose mode somewhere or a shortcut that would be equivalent to "open as interactive, then load file x"
<pango> not afaik, but I didn't really feel the need to use the interpreter that way... When I do, I run it inside emacs...
<zedrdave> I know... I usually use tuareg and it does it for me...
<zedrdave> but right now I need to use BBedit on OS X... which is nice and works...
<zedrdave> except for the part where I need to run the file.
<zedrdave> but anyway, thanks for taking the time...
<zedrdave> while I'm at it, I have another much more rtfm-like one: what's the list -> array conversion function (keep forgetting it, can't find it in the doc)...
<pango> Array.of_list I suppose
<zedrdave> damn. why was I trying of_List all along... :/
<zedrdave> thnx
<pango> for previous question, if you use a compiler (ocamlc or ocamlopt) instead of ocaml, you can try -i flag
<pango> it will display inferred types, but not the expressions themselves (that will just get evaluated)
<zedrdave> nah, it's really small scripts, I don't compile it, I merely want to check it produces the right function prototypes...
<zedrdave> this is halfway there ;)
<zedrdave> it would still help getting expressions
<pango> well, if you look closely at ocaml toplevel, it's just a loop bolted on top of the bytecode compiler ;)
<zedrdave> I see...
<zedrdave> oh, I'm sure it wouldn't be that hard to put together a shel exec...
<zedrdave> just being lazy and trying to figure out The Best Way(tm)
<zedrdave> any way to load toplevel with a certain cmd by default (e.g. #use thisfile)
<pango> I think it uses ~/.ocaml (or is it ~/.ocamlrc ?)
<zedrdave> ok... g2g, but I'll check into that later... thanks for all the help
<pango> ~/.ocamlinit
<pango> yes, that's it
love-pingoo has joined #ocaml
zedrdave has quit []
Tachyon76 has joined #ocaml
Revision17 has joined #ocaml
lchou1 has joined #ocaml
revision17_ has quit [Read error: 110 (Connection timed out)]
slipstream has joined #ocaml
slipstream-- has quit [Read error: 110 (Connection timed out)]
ski has quit [Connection timed out]
ski has joined #ocaml
finelemon has joined #ocaml
finelemo1 has quit [Read error: 110 (Connection timed out)]
mikeX has joined #ocaml
chessguy has joined #ocaml
zmdkrbou has quit [Read error: 104 (Connection reset by peer)]
zmdkrbou has joined #ocaml
Schmurtz has quit [Read error: 113 (No route to host)]
Purice has joined #ocaml
chessguy2 has joined #ocaml
<pango> For what it's worth, just found Kaya... http://compsoc.dur.ac.uk/kaya/ ... A language for web development that seems to share a lot of properties with ocaml... The way it's used look more like a statically typed PHP, however, nothing fancy
chessguy has quit [Nick collision from services.]
chessguy2 has quit [Client Quit]
andreas_1 has joined #ocaml
<andreas_1> hi all
<mikeX> pango: it's syntax hearts my eyes though
love-pingoo has quit [Read error: 110 (Connection timed out)]
love-pingoo has joined #ocaml
<andreas_1> is there something like enums in enums ocaml?
<mikeX> andreas_1: can you give an example?
<andreas_1> I would like to iterate over an array with arr.(STATE_X) where X can be 1 to 10
<mikeX> hm, I still don't understand
<pango> he's looking for ordered constructors, or something like that... I don't think there's an equivalent in ocaml
<andreas_1> well I could use variable declarations such as "let state_1 = 1 and state_2 = 2 ..." and then use those variables to index the array, but...
<andreas_1> it's not very nice since those variables are not really variable but constant throughout the program
<andreas_1> any ideas?
<pango> let states = [| STATE_1; STATE_2; STATE_3; STATE_4; STATE_5; ... |] ?
<pango> then use Array.iter or Array.iteri over states ?
<andreas_1> and STATE_1 etc. are constructors?
<pango> yes
<andreas_1> but what if I want to do arr.(STATE_3) <- somevalue?
<andreas_1> that would force me to use a hashtbl, right?
<pango> arrays indexes are ints, no matter what
<andreas_1> that's the problem :)
<pango> actually you could use Obj.magic to get constructors interval value, but I don't know if it's considered good practice ;)
<pango> # type states = STATE_1 | STATE_2 | STATE_3 | STATE_4 | STATE_5 ;;
<pango> # (Obj.magic (STATE_3):int ) ;;
<pango> - : int = 2
<andreas_1> looks scary
<pango> the safest way is to write mapping functions
<pango> let int_of_state = function
<pango> | STATE_1 -> 1
<pango> | STATE_2 -> 2
<pango> ...
<andreas_1> but I want easy syntax, I will have to use those indices all over the place ;)
<ppsmimou> why don't you define the type state = int
<ppsmimou> and hide it in a module
<ppsmimou> ?
<andreas_1> can you give an example, pls?
chessguy has joined #ocaml
<ppsmimou> type state = int
<ppsmimou> let int_of_state s = s
<ppsmimou> etc.
<ppsmimou> of course you say that int_of_state : state -> int
<andreas_1> I don't get it
<ppsmimou> here your state don't really need to be an inductive type
<ppsmimou> just using an int would be better
<ppsmimou> but if you want to have mor type-safety
<pango> then you hide it with an abstract type ?
<ppsmimou> yes
<ppsmimou> that's I would do
<ppsmimou> +what
<ppsmimou> having numerous constructors for a type is often the sign of a design problem
<pango> then they couldn't be used directly as array indexes, the only win is that mapping functions are straightforward ;)
<ppsmimou> of course, hiding the array functions in the module too would be much nicer
<andreas_1> couldn't I just create constants with ints as values?
<pango> that's a possibility, if you give up some type safety
<pango> STATE_2 + 2 will be correctly typed, for example ;)
<pango> (or rather state_2 in that case; capital will no longer be usable)
<andreas_1> ok, I think I could live with that, how can I create constants in ocaml?
<ppsmimou> let state_2 = 2
<pango> yes
<andreas_1> hmm, ok so I will have to go with that I guess, thx for your help
<mikeX> andreas_1: maybe you are thinking about your problem in the wrong way
<andreas_1> how?
<mikeX> I don't know really, I'm just speculating that there might be a way to express it more naturally in ocaml
<andreas_1> I would like to use some kind of constant identifiers instead of integers as indices
<mikeX> *fan*
<mikeX> oops, wrong window yet again
<andreas_1> sorry guys, I have to go, see you tomorrow
<pango> if you use _only_ those constructors, you could use a trick: http://www.pastebin.be/1065/
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <-"]
<pango> it works because the .() is just syntactic sugar for Array.get and Array.set, no matter what module is called Array in the context :)
<andreas_1> would that change the default behaviour of array?
<pango> well, it shadows the usual Array module, so yes
<mikeX> I think that's the first time I see the 'include' statement
<mikeX> interesting
<andreas_1> wouldn't that break code that tries to use both array implementations at the same time?
<pango> yes it would, that's why I mentionned the restriction above
<andreas_1> hmm, I think I will stick with the " let state_1..." solutions, but thx for the idea
<andreas_1> bye
<pango> if you don't use strings that much, you could shadow String instead ;)
andreas_1 has quit []
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
Smerdyakov has joined #ocaml
JKnecht is now known as Lycurgus_
love-pingoo has quit ["Leaving"]
Schmurtz has joined #ocaml
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
shawn has quit ["This computer has gone to sleep"]
pango is now known as pangoafk
Tachyon76 has quit [Read error: 110 (Connection timed out)]
lchou1 has quit ["Leaving"]
smimou has joined #ocaml
shawn has joined #ocaml
shawn has quit [Client Quit]
shawn has joined #ocaml
khaladan has joined #ocaml
pangoafk is now known as pango
love-pingoo has joined #ocaml
Submarine has quit ["Leaving"]
kral has joined #ocaml
_JusSx_ has joined #ocaml
<_JusSx_> hi ocaml ppl
<ketty> hello _JusSx_
<_JusSx_> ketty: what's up?
_JusSx_ has quit [Client Quit]
joshcryer has joined #ocaml
teop has joined #ocaml
Tachyon76 has joined #ocaml
Purice has quit [Client Quit]
Tachyon76 has quit ["Leaving"]
chessguy has joined #ocaml
kral has quit [""I'll say it again. In the land of the free, use your freedom of choice.""]
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- The future of IRC"]
zedrdave has joined #ocaml
Lycurgus_ is now known as JKnecht
exa has joined #ocaml
mikeX has quit ["zzz"]
Skal has quit [Remote closed the connection]
ppsmimou has quit [Read error: 113 (No route to host)]
smimou has quit ["bli"]
gim has quit [Read error: 101 (Network is unreachable)]
joshcryer has quit [Read error: 104 (Connection reset by peer)]
gim has joined #ocaml
ppsmimou has joined #ocaml
khaladan has quit [Connection timed out]
teop has quit [Remote closed the connection]
love-pingoo has quit ["Connection reset by by pear"]
Olathe has joined #ocaml
teop has joined #ocaml