<palomer>
GEdit.combo_box_entry <--does anyone know how to remove entries from this beast?
<palomer>
entries in the combo box
<palomer>
(not the entry)
Associat0r has quit []
<tsuyoshi>
palomer: remove them from the model
seafood has joined #ocaml
marmotine has joined #ocaml
<palomer>
hrmph
<palomer>
removing them the tree also works
* palomer
is confused
<palomer>
night!
<tsuyoshi>
a tree is a model
<tsuyoshi>
models are either lists or trees
<tsuyoshi>
or you can roll your own model, but I've never heard of anyone actually doing that
Yoric[DT] has joined #ocaml
seafood_ has joined #ocaml
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood_ has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
OChameau has joined #ocaml
zakiazigazi has left #ocaml []
subconscious has joined #ocaml
tcr has joined #ocaml
ozy` has quit [Read error: 104 (Connection reset by peer)]
Snark has joined #ocaml
jonafan has joined #ocaml
jonafan_ has quit [Read error: 110 (Connection timed out)]
GustNG has joined #ocaml
Linktim has joined #ocaml
Linktim_ has joined #ocaml
delamarche has joined #ocaml
Linktim has quit [Read error: 110 (Connection timed out)]
Linktim_ has quit [Read error: 110 (Connection timed out)]
DroneZilla has joined #ocaml
DroneZilla has left #ocaml []
subconscious has quit [Read error: 104 (Connection reset by peer)]
subconscious has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
tcr has quit ["Leaving."]
subconscious has quit ["Leaving"]
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
seafood_ has joined #ocaml
seafood has quit [Read error: 104 (Connection reset by peer)]
marmotine has quit [zelazny.freenode.net irc.freenode.net]
ulfdoz has quit [zelazny.freenode.net irc.freenode.net]
|jedai| has quit [zelazny.freenode.net irc.freenode.net]
ski_ has quit [zelazny.freenode.net irc.freenode.net]
bacam has quit [zelazny.freenode.net irc.freenode.net]
hcarty has quit [zelazny.freenode.net irc.freenode.net]
|jedai| has joined #ocaml
ski_ has joined #ocaml
bacam has joined #ocaml
hcarty has joined #ocaml
marmotine has joined #ocaml
ulfdoz has joined #ocaml
seafood_ has quit []
seafood has joined #ocaml
Linktim has joined #ocaml
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
itewsh has joined #ocaml
mishok13 has quit [Read error: 110 (Connection timed out)]
seafood has quit []
guillem_ has joined #ocaml
vpalle has joined #ocaml
Linktim_ has joined #ocaml
subconscious has joined #ocaml
Yoric[DT] has joined #ocaml
<Yoric[DT]>
Mmmhhh....
<Yoric[DT]>
I'm trying to write something along the lines of
<Yoric[DT]>
exception A = Foo.B
<Yoric[DT]>
It doesn't seem syntactically correct although it's in the documentation
<Yoric[DT]>
Any idea?
<ertai>
Yoric[DT]: you have to repeat the type
<Yoric[DT]>
Which type?
<ertai>
A of int
<flux>
hmm
<Yoric[DT]>
And if it's a constructor without arguments?
<ertai>
are you using camlp4
<flux>
module Foo = struct exception B of int end
<ertai>
Yoric[DT]: good point
<flux>
exception A = Foo.B
<flux>
works for me?
<kig>
it works in the repl at least
<Yoric[DT]>
I'm trying to do it in a signature.
<flux>
ocamlc -i it :)
<ertai>
hum
<Yoric[DT]>
tssss
<flux>
hmm, apparently the equality doesn't appear anymore in the interface
<flux>
perhaps you cannot do that :-o
<Yoric[DT]>
Well, it doesn't seem to work in the implementation either.
<flux>
or perhaps they still are the same type..
<Yoric[DT]>
Oh, my bad, in the implementation it works.
<Yoric[DT]>
But not in the interface :/
<flux>
hmm
<flux>
it works for me
Linktim has quit [Read error: 110 (Connection timed out)]
<flux>
but, does it matter that the equality isn't visible in the interface?
<Yoric[DT]>
Well, I don't know.
<flux>
this works: modeemi.fi/~flux/foo.ml
filp has quit ["Bye"]
<flux>
I don't know if the case would be different with different source files, but I suppose it would be a bug if it were, right?
<Yoric[DT]>
I suppose, yes.
vpalle has quit ["Leaving"]
itewsh has quit [Remote closed the connection]
<Yoric[DT]>
Oops, time to go.
<Yoric[DT]>
Cheers,
Yoric[DT] has quit ["Ex-Chat"]
subconscious has quit [Read error: 104 (Connection reset by peer)]
subconscious has joined #ocaml
|jedai| is now known as Jedai
guillem_ has quit [Remote closed the connection]
smimram has joined #ocaml
OChameau has quit [Read error: 113 (No route to host)]
smimou has quit [Read error: 110 (Connection timed out)]
Axioplase has joined #ocaml
Snark has quit ["Ex-Chat"]
tomh_-_ has joined #ocaml
Kopophex has joined #ocaml
rhar has joined #ocaml
<palomer>
hullo
<palomer>
how do I insert into a GTree.model?
<palomer>
I'm trying to use GEdit.entry_completion
sbok has quit [Remote closed the connection]
sbok has joined #ocaml
romildo has joined #ocaml
<romildo>
Hi.
<romildo>
How do I make a list containing widgets of different types? Let's say I have two widgets: entry (a text entry widget) and combo (a combo box). How a construct a list containg them? My concern is with the types.
<romildo>
s/How a/How I
<palomer>
erm
<palomer>
I think most widgets are a subtype of widget
rogo has quit [Read error: 110 (Connection timed out)]
GustNG has quit [Read error: 104 (Connection reset by peer)]
<romildo>
the direct conversion does not work.
<romildo>
(combo :> Gtk.widget) gives me the error:
<romildo>
This expression cannot be coerced to type Gtk.widget = [ `gtk | `widget ];
<romildo>
it has type GEdit.combo_box_entry but is here used with type [< Gtk.widget ]
<romildo>
But combo#as_widget works as I expect.
Submarine has joined #ocaml
vpalle has joined #ocaml
vpalle has quit [Client Quit]
longh has joined #ocaml
<romildo>
My system has its locale set to en_US.ISO-8859-1, and I use national characters from that locale (á for instance). My lablgtk2 test application does not show labels with such characters, and outputs the message
<romildo>
Invalid UTF-8 string passed to pango_layout_set_text()
<romildo>
How do I make the application deal with my strings in en_US.ISO-8859-1 ?
<palomer>
ahh, righto
<palomer>
dunno
jeddhaberstro has joined #ocaml
<palomer>
hmm
<palomer>
anyone know how to set a callback for when the user selects an item from a combo_box ?
<romildo>
I have just used the following code in my test program:
<romildo>
GEdit.combo_box_entry_text ~strings:(List.map Glib.Convert.locale_to_utf8 strings) ~packing:(table#attach ~left:1 ~top:i) () in
<romildo>
where strings is a list of strings with the options for the combo box.
<palomer>
that's giving you the error?
<romildo>
no, it is working.
<romildo>
do you mean the locale error
<romildo>
?
<romildo>
the function Glib.Convert.locale_to_utf8 solved it.
<palomer>
ah, gotcha
<palomer>
you wouldn't happen to know how to get the current selected item in a combo box, would you?
<romildo>
not yet. I have just started experimenting with combo box. This is after a few years witout programming in OCaml.
<palomer>
hmm
<romildo>
I mean, the last time I developed an application in OCaml using lablgtk was 2 years ago.
<palomer>
if you figure out what the combo box signals are
<palomer>
let me know
itewsh has joined #ocaml
Amorphous has quit ["shutdown"]
rwmjones_ has joined #ocaml
<romildo>
let (combo,_) as x = GEdit.combo_box_entry_text ~strings ~packing () in
<romildo>
match GEdit.text_combo_get_active x with
<romildo>
Some x -> prerr_endline x
<romildo>
| None -> prerr_endline "NONE"
<romildo>
It seems that the function GEdit.text_combo_get_active can be used to get the active selection in the combo box.
<palomer>
true
<palomer>
but...what's the signal?
jynxzero has quit [Read error: 110 (Connection timed out)]
<palomer>
when the user scrolls through the combo box and presses enter on one of the entries...
<palomer>
how do I catch that
<palomer>
and it returns a string!
<palomer>
it's the pressing enter that bothers me
<palomer>
mouse clicks work fine
<romildo>
Isn't it combo#entry#connect#changed
Axioplase has quit [Remote closed the connection]
<romildo>
?
<palomer>
for enter?
Axioplase has joined #ocaml
<palomer>
entry#connect#activate
<palomer>
BUT
<palomer>
that doesn't work if you press enter in the combo box
<romildo>
It worked for me with the mouse. Let me see with the keyboard.
<palomer>
works for mouse
<palomer>
but not keyboard
<palomer>
heck, doesn't work for mouse
<palomer>
combo#connect#changed <--works for mouse
<palomer>
entry#connect#activate <--works for pressing enter in the entry
<romildo>
works also for the keyboard, but for every change in the text.
<palomer>
right
<palomer>
but I'm scrolling down the combo box
<palomer>
and pressing enter
<palomer>
that may not change the entry
<palomer>
and even if it does
<palomer>
there's no way to find out what element of the combo box is selected
<palomer>
combo#active returns -1
<palomer>
btw, if you're writing an autocompletion combo_box
<palomer>
I have the code
<romildo>
I want to port an application I have written in Java to OCaml, but it is low priority. So for now I am just experimenting with the widgets I would use.
Amorphous has joined #ocaml
<romildo>
In fact I am not sure if I will port it to OCaml or to Haskell.
<palomer>
I've tried gtk in both
<palomer>
gtk is more complete in ocaml
<palomer>
especially treeview
<romildo>
When programming in Java I miss very much the functional features in the language.
<subconscious>
public Option<String> f(String s) {
<subconscious>
is here
<palomer>
entry_completion is making me slightly mad!
Linktim_ has quit ["Quitte"]
<palomer>
it looks like I have to rely on the entry to do everything
itewsh has quit [Read error: 60 (Operation timed out)]
itewsh has joined #ocaml
<olegfink>
uh, functional java. weird.
<olegfink>
on a side note, there's ciml which inlines C in ocaml code.
<olegfink>
was there any efforts on making something (probably a camlp4 module?) which would take some more imperative notation, for example, something C-like?
<olegfink>
there aren't many optimizations that can be acheived on preprocessing stage as I can see it, but still
rpg has joined #ocaml
<palomer>
sml has something like that
<rpg>
let inverse = function x -> -x;; <---works great..except when i try to use a float number
<olegfink>
looks more or less like what I was about
Axioplase has joined #ocaml
<rpg>
palomer: it wont let me enter a float
<rpg>
it says type int
<rpg>
and also..is that the best way to declare a function ?
<flux>
rpg, ocaml doesn't have overloading. that leads to that operators such as +, - and prefix - are for integers while operators such as +., -. and prefix -. are for floats
<flux>
rpg, a preferrable way would be to use let inverse x = -x
<palomer>
and ~ is unary negation in ocaml
<flux>
but the keyword function has its uses
<palomer>
for floats
<palomer>
I think
<flux>
palomer, yeah, but you don't need to use it unless you wish not to use parenthesis..
<flux>
(it's actually ~- and ~-.)
itewsh has quit ["KTHXBYE"]
<rpg>
flux: val inverse : int -> int = <fun>
guillem has joined #ocaml
<rpg>
i want it to be float -> float
<romildo>
subconscious: I am curious about closure implementation in Java 7. Do you know whether the alpha/beta versions of Java 7 already has something?
<rpg>
oh
<flux>
rpg, let inverse x = -.x
<olegfink>
rpg: use -. instead of -
<rpg>
oooh
<rpg>
ok
<rpg>
thx
<palomer>
let inverse x = ~x
<rpg>
so use . as suffix
<rpg>
use . as suffix to - or prefix to x
<rpg>
which one
<flux>
palomer, that's not valid.
<flux>
palomer, btw, consider the collision with optional label syntax
<flux>
(or labelled labels)
<flux>
(hmph, s/labels/arguments/)
<olegfink>
rpg: floating point operations all have dot after them, like +., -., *., /. etc.
<rpg>
ooh ok
<palomer>
ah, righto
<rpg>
another question: i type ocaml<enter> and i get the # prompt
<rpg>
how the f*k do i get out now
<rpg>
the proper way
lde has quit [Remote closed the connection]
<olegfink>
exit 0 ;;
<rpg>
thx
delamarche has quit []
<rpg>
so then let abs a = if a >= 0 then .a else -.a ;;
<rpg>
is that correct ?
<olegfink>
what is .a?
<rpg>
a represented as float ?
<rpg>
dunno
<rpg>
lol
<rpg>
i want to do abs(enter-float-number-here)
<olegfink>
ocaml is a strongly typed language, you usually can't cast values.
<rpg>
i dont mean to
<rpg>
i want from float to float
<olegfink>
so a is already a float
<olegfink>
it's inferred from -.a, as prefix -. is float -> float
<rpg>
but thats the else
<rpg>
what if there was no else
<olegfink>
if ... then .. else is a value
<olegfink>
so both then and else expressions should have the same type
<rpg>
consider the following: let abs a = if a >= 0 then a;;
<olegfink>
so 'then' type is inferred from 'else' in your case
<rpg>
doesnt even work
<rpg>
lol
<olegfink>
that's because omitting an 'else' clause implicitely adds 'else ()'
<rpg>
so i need an else
<olegfink>
so 'then' clause should be of type unit too, hence the error you get
<olegfink>
yep.
<rpg>
what if i dont want an else...what do i do
<rpg>
like else do nothing...
<rpg>
or else continue with the program
<olegfink>
then you don't write else
<rpg>
but you just said i need an else
<rpg>
lol
<olegfink>
you need an else if your 'if' returns a value
<olegfink>
it basically doesn't if you use it as a control flow statement like in imperative languages
<rpg>
im confused
<olegfink>
if you're familiar with C, ocaml's 'if' is more like a ternary '?:'
<rpg>
im familiar with C but i dont know what '?:' means lol
Submarine has quit ["Leaving"]
<olegfink>
think of if as a function, which gets three agruments, evaluates the first and then returns either of two others
<rpg>
but anyways...going back..let abs a = if a >= 0 then a else continue?
<olegfink>
continue to where?
<rpg>
to the next line of the program
<olegfink>
abs is a function, which should return a value
<olegfink>
more precisely, (abs 3.4) should be a float value 3.4
<olegfink>
(paratheses added for visualisation purposes)
<rpg>
yes
<rpg>
so what do i put for else
hkBst has joined #ocaml
<olegfink>
so there isn't any 'next line' you're going to continue to
<olegfink>
in the case of abs, obviously -.a
<rpg>
lol
<rpg>
u dont understand
<rpg>
ok
<rpg>
lets do it in english
<rpg>
if a number is greater than 0 then return the number;;
<olegfink>
and what to do if it isn't?
<rpg>
how would i translate that
<rpg>
to ml
<rpg>
nothing....absolutely nothing...continue to the next line of the code and do what that says
<olegfink>
let's move from english to C. how would you write such a function?
<rpg>
ok
<rpg>
in c
<rpg>
double a; if (a >= 0) { printf("%lf",a); }
<olegfink>
uhm, I don't see a function definition here. weren't we speaking about functions?
<rpg>
ooh
<rpg>
ok sorry
<rpg>
le me retype that
<olegfink>
you can write exactly this in ocaml, if a>=0 then print_float a
<olegfink>
this is valid because print_float returns void
<olegfink>
which is called 'unit' in ocaml
<olegfink>
you can check its type:
<olegfink>
# print_float ;;
<olegfink>
- : float -> unit = <fun>
<rpg>
double z (double a) { if (a >= 0) { return a; }
<rpg>
}
<olegfink>
unfortunately, that won't compile, because you're lacking a return in case if fails.
<olegfink>
the very same thing goes for ocaml
<rpg>
i think i understand now
<rpg>
i need to return something
<rpg>
no matter what
<olegfink>
yeah, because you declare z as float, it should always return some float.
<rpg>
hmm ok
<rpg>
le me rethink my layout here
romildo has left #ocaml []
Yoric[DT] has joined #ocaml
<olegfink>
actually, you really should read some book on ocaml or functional languages in general
<rpg>
im reading some tutorials
<rpg>
slowly starting to understand
<rpg>
i like c's idea better though when u just initialize them and thats it
<xevz>
Initialize what?
<xevz>
Functions?
<rpg>
no
<rpg>
double and int
<rpg>
so
<rpg>
lets say
<xevz>
Aside from O'Caml "trying" to determine the data type and you specify it manually in C, what's the difference? :P
<rpg>
i dont know yet but for now it seems confusing lol
<xevz>
Heh.
<xevz>
let z = 2.0;;
<xevz>
double z = 2.0;
<xevz>
Not that different. ;)
<rpg>
if abs(a) > 0 then do_something;; <---- i dont need an else there correct ?
<rpg>
because its not a function..just a condition
<olegfink>
if do_something has type unit, then it's correct.
<rpg>
type_unit meaning an action correct ?
<olegfink>
xevz: well, I remember myself starting to learn ocaml. there was apparently some difference at first...
<xevz>
Unit can be described as being equal to 'void' in C... :)
<olegfink>
rpg: no, unit means nothing.
<rpg>
ooh
<rpg>
ok
<olegfink>
it's a special type for representing nothing :-)
<olegfink>
which does even have one value, written as ().
<xevz>
olegfink: Of course there are differences, two completely different programming paradigms after all... ;)
<rpg>
wait
<xevz>
But declaring a label was never that confusing. :)
<rpg>
if abs(a) > 0 then function2(a);;
Asmadeus has quit [Read error: 104 (Connection reset by peer)]
<rpg>
function2(a);; <---that is not necesarrly void
Asmadeus has joined #ocaml
<rpg>
could be a function with a return value
<olegfink>
you should really understand that result of a function application is a value just like any other
<olegfink>
so if function2 has the value of, say, int, your 'then' clause inherits type int and so should be 'else'
Associat0r has joined #ocaml
<rpg>
give me an example when u dont need else
<rpg>
for example going back to the C example:
<olegfink>
2257 olegfink | you can write exactly this in ocaml, if a>=0 then print_float a
<rpg>
^--ok so lets say i have function abs
<rpg>
if a >=0 then abs(a) ;;
<rpg>
that should work
<rpg>
correct ?
<rpg>
oops
<rpg>
then print_float abs(a);;
<olegfink>
substituting 0 for 0. it should.
<rpg>
ok
<olegfink>
remember you don't usually do such things in your code
<olegfink>
like printing inside functions
<olegfink>
(when those functions are meant to return values, that is)
<olegfink>
like abs.
<olegfink>
xevz: on a side note, can you give a rationale on why (>>) is still not in Pervasives? :-)
<olegfink>
that is, let (>>) x f = f x
<olegfink>
so you can do -.3 >> abs >> print_float
<xevz>
No idea. :P
<rpg>
ok
<rpg>
so how do i do else if
<rpg>
they have to be nested ?
<xevz>
Pattern matching. :)
<olegfink>
yeah, just remember to think of (if...then...else) as one value (or a function application, if you want)
<rpg>
if expression1 then a else if expression2 then b else if expression3 then c else d;;
<rpg>
would that be correct ?
<olegfink>
should be, just watch out for types
lde has joined #ocaml
<rpg>
ok
<rpg>
thx
guillem has quit [Remote closed the connection]
<olegfink>
# [1; 2; 3] >> List.map (fun x -> x*3) >> List.filter (fun x -> x < 8) >> List.iter print_int ;;
<olegfink>
36
<olegfink>
perhaps a more readical example, it's almost impossible to write with parantheses
rwmjones_ has quit ["Closed connection"]
<olegfink>
haskell has all kinds of those things, I wonder why ocaml hasn't got any in Pervasives
<rpg>
i dont even know what u typed there
<rpg>
lol
<rpg>
i think i came up with something brb le me type it
<olegfink>
s/readical/radical/
<xevz>
olegfink: You could on the other hand write it with some lables and "ins". :P
<rpg>
exit 0;; can be considered as a return value right ?
<rpg>
for example abs x = if x < 0 then -.x else exit 0;;
<olegfink>
exit has a type int -> unit
<rpg>
that is correct ?
<olegfink>
no
<rpg>
oh
<olegfink>
-.x is float and (exit 0) is unit
<rpg>
k
<rpg>
brb
<olegfink>
xevz: that won't improve readability, will it?
seafood has joined #ocaml
<xevz>
olegfink: Well, it's better than a lot of parentheses... :P
<rpg>
question
<rpg>
z = x*.x+.x*.y+.y*.y ;; or just z = x*.x+x*y+y*y;;
<xevz>
+. is of type double -> double -> double
<xevz>
+ is of type int -> int -> int
<xevz>
:)
<xevz>
And a tip for you: spaces between operators aren't a bad thing. ;)
<rpg>
so
<rpg>
which one is it then
<rpg>
do i need to add the dot to all of them
seafood has quit []
<xevz>
Yes.
<xevz>
You can't mix double and int...
<rpg>
ok
<rpg>
let a_function param1,param2 = param1 *. param2
<rpg>
;;
<rpg>
is that correct ?
<xevz>
Parameters are separated by space, not comma.
<xevz>
If you would, you already would have known that you can't mix the different operators, what a 'unit' is, that parameters are separated by space, and so on.
<xevz>
No, it's good. :)
<rpg>
its good for some1 who is just looking for references
<xevz>
Isn't that what you're doing already? ;)
<rpg>
somewhat
<xevz>
Anyway, I think that tutorial is great.
<rpg>
im learning from scratch
<olegfink>
heh, I can't judge here, I started to learn ocaml in 9th grade class
<xevz>
:P
<rpg>
hehe
<olegfink>
so, it was painful at times but I had a living tutorial
<rpg>
whats wrong here: abs(x)**.(1/3)
<rpg>
it says **. unbound value
<xevz>
The operator '**.' does not exist? ;)
<rpg>
but ** does
<olegfink>
adn 1/3 is probably 0.
<olegfink>
*and
<xevz>
Mm.
<olegfink>
you should have known it from C
<rpg>
and if u add a . it means ure doing floats
<olegfink>
right.
<xevz>
rpg: In the case of **, it takes two floats.
<xevz>
"What does all that stuff about float -> float -> float mean?"
<xevz>
No, 1.0 /. 3.0
<rpg>
ooh
<rpg>
C is so much easier....
<xevz>
That's because you're used to C.
<xevz>
Read the tutorial, it doesn't suck as much as you think. And you really seem to need it to get the basics down. :)
<xevz>
It's so much easier to experiment when you have an idea of how something work. :)
<rpg>
thats true
<rpg>
i figure expirience is the best teacher tho
<xevz>
Me too, in the long run.
<xevz>
You can't learn everthing by reading.
<xevz>
But you need to start somewhere... :)
Jedai has joined #ocaml
<rpg>
by talkin to you for these 5 min i learned more than 2hours of browsing last night
<rpg>
just cos i kept trying different shit
<xevz>
I'm not a stranger to answering questions. But I would recommend you to read that tutorial, and ask here when there is something written in it you don't understand. Or when you want to understand something that isn't written in it. :)
<rpg>
lol
<rpg>
thats cool i just needed to get started
<rpg>
if abs(x) == 1.0 then 2 else 3;;
<rpg>
oops
<rpg>
if abs(x) == 1.0 then 2.0 else 3.0;;
<olegfink>
there isn't == in ocaml
<rpg>
oo
<subconscious>
yeah really
<subconscious>
this is not how to program
<subconscious>
"guessing"
<subconscious>
does not work well
<rpg>
lol
<xevz>
Besides, it is a bit tiresome to explain things already written in a far more descriptive way. :)
<xevz>
rpg: Btw, do you have any previous experience with functional programming?
<xevz>
Then, learning the syntax of O'Caml won't be your least problem. :)
<rpg>
ive tried perl,java,c and a couple others and so far caml seems to be the most retarded...except for vbasic
longh has quit [Read error: 104 (Connection reset by peer)]
<rpg>
its not the syntax its the grammar that bothers me.... i understand if then else and for and while etc.
<xevz>
Perl is procedual, Java is object oriented, C is procedual. O'Caml is functional, with some support for procedual and objective oriented programming.
<rpg>
but this casting confuses me
<xevz>
Um, syntax == grammar when it comes to programming languages. ;)
<rpg>
umm sort of yes
<rpg>
in C i would not get an error doing 1.0/3 for example
<rpg>
and a == b is common in many languages
<xevz>
That's because C isn't as strongly typed as O'Caml.
<xevz>
Well, if you're going to learn O'Caml, stop compairing it to C.
<rpg>
even if java has -eq i think u can still use ==
<rpg>
for strings
<rpg>
i guess thats what my problem is
<xevz>
Java as String.equal.
<xevz>
has*
<xevz>
And no "foo" == "foo" isn't valid in Java.
<xevz>
Let me tell you now, O'Caml isn't anything like any of the languages above.
<xevz>
It's completely different.
<olegfink>
xevz: it's valid
<olegfink>
you're just comparing the pointers
<xevz>
Yeah, that's true.
<rpg>
== worked for me in java
<rpg>
lots of times
<xevz>
It's valid, but it doesn't do what you want.
<rpg>
sometimes id be like shit its a string and then "wait a minute it still works"
<xevz>
Hm, perhaps they fixed it up in later versions of Java.
<olegfink>
actually, the better you jvm the better you chances that == would work with strings :-)
<xevz>
Mm.
<olegfink>
*your chances
<xevz>
I don't think it worked as expected in 1.4...
marmotine has quit ["mv marmotine Laurie"]
<olegfink>
the thing is that any decent jvm tries to 'clean up' strings table by collecting references to physically equal strings
<xevz>
Mm.
Associ8or has joined #ocaml
<olegfink>
so if you have two equal strings, chances are that they're really the same string in memory
<olegfink>
but of course you shouldn't depend on that
<xevz>
Yeah, I don't think 1.4 did that (very well). But it's been a long time since then... :P
<rpg>
my understanding is that its anything that produces undesirable effects
<rpg>
such as inputs
<Eridius>
a side effect is a change to the general state of the world
<Eridius>
you know you have side effects if calling the function with the exact same output multiple times is different than calling it once and saving the result
<rpg>
but anything is a change
<Eridius>
is it? Does sqrt() cause a change to the world?
<Eridius>
you can call sqrt(42) a billion times, or you could call it once. No difference
<rpg>
oh
<rpg>
seting a variable is a side effect ?
<Eridius>
calling something which modifies a ref, or which prints output, or manipulates the filesystem, or anything like that is a side effect
<Eridius>
any sort of mutation or I/O
<rpg>
changing a variable..is that a side effect ?
<rpg>
since it causes a change
<Eridius>
sure
<rpg>
so then its impossible to have a side effect program..considering complex programs
<rpg>
err
<rpg>
to have a program with no side effects
<Eridius>
a program with no side effects is pretty useless, because whatever it calculates would never escape the program
<Eridius>
this is why in Haskell, the entrypoint to a program (Main.main) is implicitly executed in the IO monad
<rpg>
as soon as i type let x = a; <--thats a side effect correct
<Eridius>
no
<Eridius>
that's not even valid inside a function
<Eridius>
now if you had a let myState = ref []; somewhere, and in your function you said myState := 5 :: myState;
<Eridius>
that would be a side effect
<rpg>
im confused
<Eridius>
why are you worrying about side-effects right now?
<rpg>
im doing a project
<rpg>
it says
<rpg>
"5. All the procedures in the program are side-effect free."
<rpg>
so i was wondering
<dobblego>
consider any expression e, then the assignment of that expression to i, then any occurrence of e can be replaced with i without affecting program outcome. If this is not true, then e is a side-effect
<rpg>
how the f*k am i suposed to display the asnwer
<Eridius>
by printing from the toplevel
<rpg>
dobblego: so then print_line would NOT be a side effect according to your theory
<dobblego>
yes it would (it's not a theory, it's the definition)
<rpg>
lol
<Eridius>
rpg: sure it would
<dobblego>
here is a program:
<dobblego>
println(x);
<dobblego>
println(y);
<dobblego>
here is another program:
<rpg>
ok
<dobblego>
oops
<dobblego>
s/println(y);/println(x);
<dobblego>
here is another program:
<dobblego>
val i = println(x);
<dobblego>
i;
<dobblego>
i;
<dobblego>
the two programs have a different outcome
<dobblego>
ergo, println(x) is a side-effect
<rpg>
how do they have different outcome
<rpg>
it looks the same to me
<Eridius>
because the first program prints x twice, the second program prints it once
<rpg>
but you have i;i;
<Eridius>
yeah, i is the result of calling println(x)
<Eridius>
he didn't say val i = (fun () -> println(x) )
<Eridius>
he said val i = println(x)
<rpg>
i dont know what the difference is Eridius
<dobblego>
if I had used that, then the program outcome is nothing in both cases
<Eridius>
rpg: I don't know what to tell you, then
<dobblego>
rpg, there is another way of looking at this definition
<dobblego>
imagine some function f
<rpg>
ok
<dobblego>
then for some expression e, if f(e); f(e); is not equivalent to val i = e;f(i);f(i); for any value of f, then e is a side-effect