<gene9>
Hello, I have a problem with revised syntax, I put transcript of attempts here http://pastebin.com/m74524a97 , can anybody take a look at it, what's wrong with this 1 liner?
<bluestorm>
hm
<bluestorm>
iirc
<bluestorm>
the "abstract type" changed back to "type t;"
zenhacker-rouan has quit [Remote closed the connection]
mordaunt has quit [Read error: 104 (Connection reset by peer)]
<jdavis_>
If I do something like: let myset = StringSet.remove "myelement" myset;; does that make an entire copy of myset minus one element, or is ocaml smart enough to realize that it's really just modifying myset?
<jdavis_>
In other words, will there temporarily exist two copies of the set "myset" (one of which is missing "myelement")?
<qwr>
jdavis_: probably. it might share some data between those sets though.
<jdavis_>
I don't quite understand.
<jdavis_>
What data would be shared?
<qwr>
the Set's are binary trees
<qwr>
i think they can share some branches after removal of one element
<tsuyoshi>
it copies, it doesn't modify
<jdavis_>
Ok.
<jdavis_>
Is there a proper way to modify a structure in-place (physically) but logically still write programs functionally?
<qwr>
jdavis_: use Hashtbl, if you want mutable set
<jdavis_>
Oh, interesting.
musically_ut has quit [Remote closed the connection]
<jdavis_>
So hash table functions modify in place?
<jdavis_>
It looks like it has both functional and generic interfaces
<qwr>
yes
<jdavis_>
So I assume the functional one makes copies.
<jdavis_>
and the generic one modifies in place.
<jdavis_>
It seems like there could be some kind of optimization for functional style... aren't functional languages highly optimizable?
<qwr>
imho they are both same (modifying in-place)
<jdavis_>
oh, ok.
<qwr>
(and () would be good value to put in the table, if you want just a set)
<jdavis_>
I don't quite understand.
<jdavis_>
So you put a value like () => a_set ?
<jdavis_>
or you mean my_set_element => ()
<jdavis_>
?
<qwr>
let t = Hashtbl.create 100 in Hashtbl.replace t "fish" (); Hashtbl.mem "fish";;
<qwr>
let t = Hashtbl.create 100 in Hashtbl.replace t "fish" (); Hashtbl.mem t "fish";;
<jdavis_>
oh, I see now. Thanks!
<jdavis_>
I see that the "functional" interface is really still an imperative interface, because it doesn't return the structure it modifies. Is there a way to program in a functional style while actually modifying the data structures in place?
<qwr>
what would really be the point of that?
darkness3477 has joined #ocaml
<jdavis_>
So that I could logically express an algorithm in functional style, without worrying about which data structures will get too large for efficient functional programming.
<jdavis_>
It would be nice if ocaml could just optimize it away.
darkness3477 has left #ocaml []
* qwr
is quite sure, that ocaml don't do it...
<jdavis_>
Ok, well, thanks. I'll look into it more to see where I might need to modify in place.
kelaouchi has joined #ocaml
<tsuyoshi>
too large for efficient functional programming? what do you mean
<qwr>
probably something like that he doesn't want to copy 100MB data structures all the time ;)
<tsuyoshi>
er.. how many entries would you put in one set?
<pango>
Sets and Maps share most of their elements across adds and removes... That's the benefit of immutable datastructures, there's no semantic difference between this and making a new copy
<pango>
and functorized interface != functional interface
<pango>
(in fact what I mean is that all the other elements _in_ the {map,set} are shared; It's the internal tree-like structure of {set,map}s that's mostly shared)
<pango>
I think complexity of operations would not be in O(log n) if more than O(log n) internal nodes were modified or copied each time
<pango>
(reminds me of a friend who asked, long ago, how OOPL could be memory efficient, with those methods stored in each object... ;) )
filp has joined #ocaml
buluca has joined #ocaml
buluca has quit [Read error: 104 (Connection reset by peer)]
<jdavis_>
Ah, thanks guys. I actually constructed a test (that's what I was doing this whole time). Sure enough, they do share most of the elements. I made a copy of a 150MB set (that just had one extra element) and it didn't affect the memory at all.
<jdavis_>
It took me a while 'cause I'm not very familiar with ocaml and I/O.
<jdavis_>
As a separate issue, I managed to construct something that apparently wasn't tail-recursive, because it ended up overflowing the stack when I was making my big set.
<jdavis_>
pango: interesting details, by the way. I'm very impressed with ocaml (and functional programming) so far.
smimou has quit ["bli"]
buluca has joined #ocaml
<jdavis_>
Ah, nevermind about the tail recursion, I figured that one out. The arguments are evaluated first, and I had my recursive call as an argument to another function.
ppsmimou has joined #ocaml
brooksbp has joined #ocaml
rwmjones has joined #ocaml
darinm has quit []
ygrek has joined #ocaml
thermoplyae has quit ["daddy's in space"]
ttamttam has joined #ocaml
brooksbp has quit []
Demitar has quit [Read error: 110 (Connection timed out)]
brooksbp has joined #ocaml
leo037 has joined #ocaml
musically_ut has joined #ocaml
brooksbp has quit []
asmanur has joined #ocaml
Demitar has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
robyonrails has joined #ocaml
hkBst has joined #ocaml
Yoric[DT] has joined #ocaml
\-Catch22-\ has quit [Read error: 113 (No route to host)]
Linktim has joined #ocaml
Linktim has left #ocaml []
musically_ut has quit ["Leaving"]
musically_ut has joined #ocaml
ttamtta1 has joined #ocaml
ttamtta1 has left #ocaml []
gim has joined #ocaml
ygrek has quit [Remote closed the connection]
piggybo2 has joined #ocaml
piggybo2 has quit ["Leaving."]
musically_ut has quit [Remote closed the connection]
buluca has joined #ocaml
Associat0r has joined #ocaml
ttamttam has left #ocaml []
jlouis_ has joined #ocaml
|Jedai| has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
flux has quit [Remote closed the connection]
jedai has quit [Read error: 110 (Connection timed out)]
pango has quit [Remote closed the connection]
kelaouchi has quit [Remote closed the connection]
flux has joined #ocaml
pango has joined #ocaml
Morphous_ has joined #ocaml
ttamttam has joined #ocaml
ttamttam has left #ocaml []
Morphous has quit [Read error: 110 (Connection timed out)]
filp has quit [Remote closed the connection]
jlouis has joined #ocaml
jlouis_ has quit [Read error: 110 (Connection timed out)]
zenhacker-rouan has joined #ocaml
zenhacker-rouan has quit [Remote closed the connection]
ttamttam has joined #ocaml
ttamttam has quit ["Leaving."]
robyonrails has quit ["Leaving"]
robyonrails has joined #ocaml
psnively has joined #ocaml
zenhacker-rouan has joined #ocaml
<zenhacker-rouan>
hi everyone
<zenhacker-rouan>
question, I have created a class in 1 file and want to reference it in another, how do I make the class definition available to the other file
<Yoric[DT]>
If you put your class (or type or value) in a file called a.ml, you can reference it as A.the_name_of_your_class .
<Yoric[DT]>
However, if you have to ask this question, my spider-sense tells me that you may not need classes.
<zenhacker-rouan>
i still get the message : Unbound class Preprocessor.smallPreprocessor
<zenhacker-rouan>
Preprocessor is the file's name (preprocessor.ml)
<zenhacker-rouan>
and the class name is smallPreprocessor
<zenhacker-rouan>
do i need something like include in the main.ml file in which i want to use the class
<Yoric[DT]>
Nope.
<Yoric[DT]>
Did you compile preprocessor.ml ?
<zenhacker-rouan>
yes
<zenhacker-rouan>
i do
<Yoric[DT]>
Are you using ocamlbuild, btw ?
<zenhacker-rouan>
nope
<zenhacker-rouan>
just a simple shell script at the moment
<zenhacker-rouan>
Im still learning ocaml
<zenhacker-rouan>
but i am aware of ocamlbuild
<Yoric[DT]>
OCamlBuild usually handles this kind of issues without problem.
<Yoric[DT]>
What files do you have atm ?
<zenhacker-rouan>
.cmo
<zenhacker-rouan>
i have preprocessor.ml
<zenhacker-rouan>
and main.ml
<zenhacker-rouan>
and would like to use the smallPreprocessor class in main.ml
<zenhacker-rouan>
i did not define any module / signature in preprocessor.ml
<zenhacker-rouan>
just the class definition
<Yoric[DT]>
You'll have a module anyway.
<zenhacker-rouan>
i first compile the preprocessor.ml
<zenhacker-rouan>
then the main.ml
<zenhacker-rouan>
, but then it fails
<zenhacker-rouan>
telling me that smallPreprocessor is unbound
<zenhacker-rouan>
i compile preprocessor.ml separately from main.ml
<zenhacker-rouan>
then link them together with a 3rd command
<zenhacker-rouan>
( i link the resulting .cmo files)
<pango>
I think you can compile the main with ocamlc -c preprocessor.cmo main.ml