<tspier2>
asymptote, are you very good with OCaml?
<asymptote>
no
<asymptote>
but I can try
<tspier2>
What function do I use to read a line of text from a file?
<asymptote>
there's a few...
<asymptote>
do you have a descriptor or a stream?
<tspier2>
Well, say I have a file, and each line has "x, y", however different values are placed in x and y. How can I make those two values be read in, so then I can use them in that equation?
<asymptote>
well, Unix.read is kind of the big one
asymptote has quit ["Leaving"]
<tspier2>
Hmm, that didn't help.
<tspier2>
pango
<tspier2>
Anyone conscious?
Submarine has quit [Read error: 104 (Connection reset by peer)]
dark_light has joined #ocaml
Submarine has joined #ocaml
<Smerdyakov>
tspier2, you should read the Pervasives manual page that I pointed you to weeks ago.
<tspier2>
Smerdyakov, if I could understand what all the arrows meant, then I would.
<Smerdyakov>
If you can't understand that, then it's time to read the language tutorial.
<Smerdyakov>
tspier2, there is no trial-and-error way to learn to use OCaml effectively. You must be willing to read.
<tspier2>
I am willing to read, if time allows during the day. There is only so much time I have to do things. I have school and homework, which is over half the day. I need to sleep, and that lives me with a quarter of the day to eat and get misc. stuff done.
<Smerdyakov>
Well, if you have time to try to program in OCaml, then you can use that time to read as much as you need to read to proceed.
<tspier2>
Okay
khaladan has quit [Read error: 104 (Connection reset by peer)]
tspier2 has quit ["Leaving"]
Submarine has quit ["Leaving"]
Sysop_fb has quit [Nick collision from services.]
Sysop_fb has joined #ocaml
ramki is now known as ramkrsna
mrsolo_ has quit [Connection reset by peer]
mrsolo_ has joined #ocaml
Smerdyakov has quit ["Leaving"]
pauldia has joined #ocaml
Snark has joined #ocaml
mikeX has joined #ocaml
mikeX has quit ["leaving"]
pango is now known as pangoafk
love-pingoo has joined #ocaml
pangoafk is now known as pango
mrsolo_ has quit [Read error: 104 (Connection reset by peer)]
srle_ has joined #ocaml
<srle_>
hi all
mrsolo_ has joined #ocaml
<srle_>
why ocaml interpreter has introspective capabilities and ocaml compiler doesnt?
<srle_>
example
<srle_>
let x = 4;;
<srle_>
x;;
<srle_>
- : int = 4
<srle_>
This means that ocaml interpreter knows the type of x.
<srle_>
Why ocaml compiler doesnt have same posibility?
<love-pingoo>
first it parses you string, then types it, then evaluates it
<love-pingoo>
once it's typed the type info is removed (when translating to bytecode)
<srle_>
Whe I type: x;;
<srle_>
where is type info stored?
<love-pingoo>
I guess you can embed kind of interactive toploop in your ocaml programs, but that's different
<srle_>
why there isnt some function like : print_poly x;;
<srle_>
that will get the type and apply correct print
<love-pingoo>
srle_: it's not stored anywhere once the code is compiled (even in the toploop)
<srle_>
OK. but?
<srle_>
let x = 4;;
<srle_>
this gets compiled and type info removed
<srle_>
how does ocaml interpretek knows type info when I type: x;;
<srle_>
I am talking about top level interactive ocaml.
<pango>
toploop does keep such info, it's necessary because it's doing something that could be called "incremental compilations"
<love-pingoo>
srle_: the toplevel parses, then types (remembers the type), then compiles to bytecode (no type info there), then prints according to the type it infered earlier
<love-pingoo>
I guess
<srle_>
ok, why there isnt such info in compiled program? or why there isn't any option to comiple program with that info?
<pango>
srle_: because most of the time it's not necessary
<love-pingoo>
mmm we could think of something similar for print_poly.. but I don't think camlp4 has access to type info
<pango>
love-pingoo: no, camlp4 has no access to types
<srle_>
something similar is called gcaml
<srle_>
but that isnt standard
<pango>
srle_: yes, adhoc polymorphism
<love-pingoo>
srle_: caml wants to be fast, that's why the bytecode (and native code) doesn't include types
<srle_>
but I think that ocaml would benefit from gcaml by adding features from it.
<love-pingoo>
srle_: they might loose some features the OCaml team really want
<love-pingoo>
typically modular compilation
<srle_>
love-pingoo : can you expain it a little, please
<love-pingoo>
you can infer at compile time which function to use instead of print_poly according to the infered type, but it excludes modular compilation
_fab has joined #ocaml
<love-pingoo>
if you have a function 'a -> unit which as a side effect prints using print_poly, then it cannot be compiled once-for-all
<love-pingoo>
instead you need to compile all the modules from source at the same time when producing the binary -- which MLton does, but is heavy
<srle_>
i think hat specialization can take place
<srle_>
for primitive types you will have several print functions
<srle_>
yes, it will give larger code but you will have something like synamic typing
<love-pingoo>
srle_: I think you didn't get my point
<pango>
ocaml has strong static typing
<srle_>
pango : and?
<pango>
if you want to add dynamic typing, it becomes a totally different language
<love-pingoo>
if you want to compile (to bytecode, without type information) a ('a -> ...) function, then you cannot use print_poly in it, otherwise, how would it distinguish between two same representations of different types (say, float and int64)
<srle_>
love-pingoo : take a look at : Printf.printf takes type infrom from the first arguemnt
<srle_>
this can be called a hack
<srle_>
same can be done from print_poly a;;
<srle_>
but the type will be taken from 'tag of a'
<srle_>
soemthing like that
<love-pingoo>
srle_: that's different, when you compile a (Printf.printf format ...) statement you know the types of you arguments
<srle_>
yes an no
<srle_>
gcaml adds ceation of generic functions
<srle_>
you can say: let f = generic and so on
<srle_>
and only generic function will look for type infrom
<srle_>
rest of the language will be the same
<srle_>
there could be a problem with classes, but I don't think that to many people develop OOP in ocaml
<pango>
if it was so simple gcaml would be finished and we would all be using gcaml by now (or maybe ocaml would have added all gcaml features, to the same effect)
<srle_>
pango : posibly
<love-pingoo>
srle_: as I said, there must be some drawbacks. Does gcaml support modular compilation ?
<love-pingoo>
is it as fast as Caml ?
<pango>
toplevel and debugger have pluggable printers (#install_printer, #remove_printer), but I suppose such mecanism cannot be used in compiled programs ?
<srle_>
love-pingoo : I think that it would be slower but I think that developers productivity will increse.