<dostoyevs>
Fast is nice. But what I like most are language features that distinguish it from other languages; that may change the programmer's view of programming in general.
<two-face>
i'm off now
<two-face>
bye
two-face has left #ocaml []
<Malkuth>
dostoyevs: It's a semi-functional language, so if you're not familiar with functional programming, that part will certainly change the way you approach problems.
<Malkuth>
dostoyevs: Also, it's the only language I know of with inferred typing.
<dostoyevs>
Malkuth: Is it more functional than LISP?
<Malkuth>
dostoyevs: Much more. Common Lisp has lots of side effects.
<Malkuth>
dostoyevs: I probably wouldn't call CL a functional language, actually.
<dostoyevs>
Malkuth: Yes, CL is not really a functional language. I will see, if I find inferred typing explained somewhere.
<pnou>
mmm, i can't see why ocaml would be much more functional thant clisp
<Malkuth>
pnou: The standard library in CL isn't functional.
<Malkuth>
pnou: There are all sorts of CL functions with side-effects.
<pnou>
well, ocaml too
<Malkuth>
Like what?
<Malkuth>
I haven't run into any yet.
<pnou>
Hashtbl
<pnou>
Buffer
<Malkuth>
Yes, but compare that to this:
<pnou>
Stack
<Malkuth>
(setf foo '(10 9 5 7))
<Malkuth>
(sort foo #'<)
<Malkuth>
Suddenly, foo is axed.
<pnou>
well it's the same with arrays
<Malkuth>
The libraries in OCaml that are non-functional are clearly labeled as such.
<pnou>
that's true
<Malkuth>
But in CL, individual functions in the standard library may or may not be non-functional.
<smkl>
aren't all variables mutable in lisp?
<Malkuth>
Yep, all variables are mutable.
<Malkuth>
Even inside a list.
<Malkuth>
(setf (nth 1 foo) 99)
<Malkuth>
You can 'setf' pretty much anything.
<Malkuth>
Even object slots.
<Malkuth>
Or even (setf (cdr foo) '(a b c))
<Malkuth>
:)
* Malkuth
loves Common Lisp.
<Malkuth>
Even better is (setf (cdr foo) foo)
<pnou>
hehe
gl has joined #ocaml
<Malkuth>
So anyhow, that's why CL isn't functional.
<pnou>
what is you definition of a functional language?
<gl>
a language where we don t care about the memory state
<gl>
('lo all)
<pnou>
so ocaml isn't a functional language
<Malkuth>
OCaml doesn't claim to be purely functional.
<pnou>
yep
<pnou>
but you said that it's more functional than clisp
<Malkuth>
It is.
<Malkuth>
Becuase you can program in a functional manner without having to worry about non-functional side-effects.
<Malkuth>
In CL, you always have to be aware of the state of your variables and what you might be overwriting.
<Malkuth>
You have to remember if the function you're calling is destructive or not, and if you will harm other variables by altering a pointer somewhere.
<pnou>
to me that doesn't make it a less functional programing language
<Malkuth>
To each his own. :)
<pnou>
:)
<Malkuth>
It's just not that often that you hear Lispers claiming theirs is a functional language.
<pnou>
to me a functional language is a language that helps the programmer to handle functions
<pnou>
so with my definition, clisp is less purely functional
<pnou>
because it can't prove things that ocaml can prove about referentiel transparency
<pnou>
but it is as functional that ocaml
<mrvn_>
pnou: But clisp is more functional because it allows for fixpoint itterators.
<pnou>
hu ?
<pnou>
Y combinators ?
<mrvn_>
yes, that stuff
<mrvn_>
In ocaml you have to resort to let rec to write a factorial function.
<pnou>
no
<pnou>
but you must use ocamlc -rectypes
<pnou>
# let y = function le -> (function f -> le (function x -> f f x)) (function f -> le (function x -> f f x)) ;;
<pnou>
let length = y (function length -> function | [] -> 0 | h :: t -> 1 + length t)
<pnou>
;;
<pnou>
val y : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b = <fun>
<pnou>
# val length : '_a list -> int = <fun>
<pnou>
# length [1;2;3];;
<pnou>
- : int = 3
<pnou>
launched with
<pnou>
dimitri@corwin:~$ ocaml -rectypes
<mrvn_>
Hmm, didn't know that one.
<mrvn_>
pnou: Why is the last "length" bound there and to which length?
<pnou>
i didn't understand
<mrvn_>
Without -rectpyes the "+ length t" would give onbound binding length.
<pnou>
that's not a problem of binding, but of typing
<mrvn_>
ah, forget it. length is bound there.
<pnou>
the y function cannot be typed without -rectypes
<mrvn_>
Why do you write "function | []..."? Is that a common custom?
<mrvn_>
The extra | I mean.
<pnou>
so that i can cut and paste the first pattern matching
<pnou>
common i don't know, but i'm not the only one :)
<mrvn_>
I saw that a few time here now.
mrvn_ is now known as mrvn
<mrvn>
Does -rectpyes make ocaml less type save or compilation slower or what is its effect apart from the y working?
<pnou>
it doesn't make it less type safe but it can accept some program errors that are typable, there are some example in the oreilly book as far as i remember
<pnou>
i don't think it slows compilation but i'm not sure