<Malkuth>
You know, SWIG did not save me any work.
<Malkuth>
Maybe I'm just using it wrong.
gl has quit [No route to host]
skylan has quit ["O_O"]
skylan has joined #ocaml
skylan has quit [card.freenode.net irc.freenode.net]
Malkuth has quit [card.freenode.net irc.freenode.net]
Dybbuk has quit [card.freenode.net irc.freenode.net]
pnou has quit [card.freenode.net irc.freenode.net]
skylan has joined #ocaml
Malkuth has joined #ocaml
Dybbuk has joined #ocaml
pnou has joined #ocaml
Dybbuk has quit [card.freenode.net irc.freenode.net]
Malkuth has quit [card.freenode.net irc.freenode.net]
pnou has quit [card.freenode.net irc.freenode.net]
skylan has quit [card.freenode.net irc.freenode.net]
physarum has quit [card.freenode.net irc.freenode.net]
mrvn has quit [card.freenode.net irc.freenode.net]
merriam has quit [card.freenode.net irc.freenode.net]
smkl has quit [card.freenode.net irc.freenode.net]
pnou has joined #ocaml
Dybbuk has joined #ocaml
Malkuth has joined #ocaml
skylan has joined #ocaml
mrvn has joined #ocaml
merriam has joined #ocaml
smkl has joined #ocaml
physarum has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
Malkuth has quit [card.freenode.net irc.freenode.net]
Dybbuk has quit [card.freenode.net irc.freenode.net]
pnou has quit [card.freenode.net irc.freenode.net]
skylan has quit [card.freenode.net irc.freenode.net]
skylan has joined #ocaml
Malkuth has joined #ocaml
Dybbuk has joined #ocaml
pnou has joined #ocaml
Dybbuk has quit [card.freenode.net irc.freenode.net]
Malkuth has quit [card.freenode.net irc.freenode.net]
pnou has quit [card.freenode.net irc.freenode.net]
skylan has quit [card.freenode.net irc.freenode.net]
skylan has joined #ocaml
Malkuth has joined #ocaml
Dybbuk has joined #ocaml
pnou has joined #ocaml
Dybbuk has quit [card.freenode.net irc.freenode.net]
Malkuth has quit [card.freenode.net irc.freenode.net]
pnou has quit [card.freenode.net irc.freenode.net]
skylan has quit [card.freenode.net irc.freenode.net]
skylan has joined #ocaml
Malkuth has joined #ocaml
Dybbuk has joined #ocaml
pnou has joined #ocaml
thierry has joined #ocaml
<thierry>
yop *
malc has joined #ocaml
mrvn has joined #ocaml
mrvn_ has joined #ocaml
physarum has quit [card.freenode.net irc.freenode.net]
mrvn_ has quit [card.freenode.net irc.freenode.net]
malc has quit [card.freenode.net irc.freenode.net]
thierry has quit [card.freenode.net irc.freenode.net]
Malkuth has quit [card.freenode.net irc.freenode.net]
Dybbuk has quit [card.freenode.net irc.freenode.net]
pnou has quit [card.freenode.net irc.freenode.net]
skylan has quit [card.freenode.net irc.freenode.net]
merriam has quit [card.freenode.net irc.freenode.net]
smkl has quit [card.freenode.net irc.freenode.net]
mrvn_ has joined #ocaml
malc has joined #ocaml
thierry has joined #ocaml
pnou has joined #ocaml
Dybbuk has joined #ocaml
Malkuth has joined #ocaml
skylan has joined #ocaml
merriam has joined #ocaml
smkl has joined #ocaml
physarum has joined #ocaml
physarum has quit [card.freenode.net irc.freenode.net]
Malkuth has quit [card.freenode.net irc.freenode.net]
malc has quit [card.freenode.net irc.freenode.net]
mrvn_ has quit [card.freenode.net irc.freenode.net]
Dybbuk has quit [card.freenode.net irc.freenode.net]
pnou has quit [card.freenode.net irc.freenode.net]
skylan has quit [card.freenode.net irc.freenode.net]
thierry has quit [card.freenode.net irc.freenode.net]
merriam has quit [card.freenode.net irc.freenode.net]
smkl has quit [card.freenode.net irc.freenode.net]
mrvn_ has joined #ocaml
malc has joined #ocaml
thierry has joined #ocaml
pnou has joined #ocaml
Dybbuk has joined #ocaml
Malkuth has joined #ocaml
skylan has joined #ocaml
merriam has joined #ocaml
smkl has joined #ocaml
physarum has joined #ocaml
malc has quit [Read error: 110 (Connection timed out)]
mrvn has quit [Read error: 110 (Connection timed out)]
MegaWatS has joined #ocaml
<pnou>
plop
<xtrm>
yop
SYStems has joined #ocaml
gl has joined #ocaml
MegaWatS has quit ["Oceania has ALWAYS been at war with Eastasia!"]
dostoyevs has quit ["ircII EPIC4pre1.042 -- This is the default quit message."]
SYStems has quit [Read error: 110 (Connection timed out)]
MegaWatS has joined #ocaml
Wazzamar has joined #ocaml
revanth has joined #ocaml
<revanth>
hi guys
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml
xkb has joined #ocaml
<revanth>
hi xkb
<xkb>
hi
<xkb>
does ocaml have exceptions?
<revanth>
i am not sure
<revanth>
i am new to ocmal
<revanth>
*ocaml
<xkb>
so am I :)
<revanth>
i came to here learn ocaml
<Wazzamar>
erm of course ocaml has exceptions :)
<xkb>
are there any papers on their implementation?
<xkb>
or design?
<Wazzamar>
well it doesn't have call/cc like sml does so its more limited than in sml
<Wazzamar>
not that I know of ...
<revanth>
Wazzamar:what advantages does ocaml have on other languages
MegaWatS has quit [Read error: 110 (Connection timed out)]
<Wazzamar>
well first and foremost its a language from the ml family so it comes with all the advantages of languages from that family as there are:
Wazzamar is now known as MegaWatS
<MegaWatS>
* parametric polymorphism
<MegaWatS>
* closures and higher-order functions
<MegaWatS>
* automatic type inference
<MegaWatS>
* pattern-matching
<revanth>
is is a interpreted lang or compiled lang
<MegaWatS>
and all the nice stuff that comes with the ml type system
<MegaWatS>
languages are usually not 'interpreted' or 'compiled', but implementations are... but the current (only) ocaml implementation is a compiler
<MegaWatS>
it supports its own bytecode format which is very portable, and also native-code compilation on some systems
<revanth>
cool
<MegaWatS>
like windows/x86 and linux/x86
<revanth>
i have to learn ocaml
<revanth>
and i will
revanth has quit ["later"]
<xkb>
Im doing research on the implementation of exception mechanisms in functional languages
<MegaWatS>
i see
<xkb>
but there aint much docs about them :(
<xkb>
arent
<xkb>
pfft.. bad english :)
<MegaWatS>
well ocaml's exception mechanism is pretty much only the standard try / catch stuff like there is in pretty much all languages (java, C++, ...) nowadays
<MegaWatS>
so i don't think its very interesting :)
<MegaWatS>
you might have a look at the ocaml sources to see how it is implemented, though
<xkb>
good idea
<xkb>
Eventually I will try to implement an exception mechanism for Clean
<MegaWatS>
clean doesn't have an exception mechanism?
<MegaWatS>
hmmm
<MegaWatS>
well it would defeat referential transparency, I think, anyway :/
<MegaWatS>
does haskell have an exception mechanism?
<MegaWatS>
well I could just look it up myself :)
<xkb>
yes
<xkb>
It has
<xkb>
using monads
<xkb>
is Ocaml lazy?
<MegaWatS>
no
<xkb>
aha
<xkb>
thats the main part of the problem
<MegaWatS>
ocaml is eager (is that the right word?), and supports side-effects
<xkb>
yes.. eager is the right word
<MegaWatS>
hmm
<MegaWatS>
yes using monads I could see how that might work ... do you then want to do a monadic implementation of exceptions in clean as well, then, or do you want to break the 'purity' for having exceptions?
<xkb>
no.. Im thinking of doing something with the "uniqueness" typing system of clean
<xkb>
but I just started the research..
<xkb>
So dont have a clue yet if this might work
<MegaWatS>
oh wait didn't haskell have an exception mechanism that worked by simply having a special "error" value that wasn't compatible with anything else and thus propagated up in the call chain until it hit a special catch clause?
<xkb>
yep
<xkb>
very ugly
<MegaWatS>
?
<MegaWatS>
whats ugly about that?
<xkb>
the propagation
<MegaWatS>
hm
<xkb>
at least in my opinion
<xkb>
+I dont know if it catches the "lower" system exceptions
<xkb>
like divide by zero
<MegaWatS>
well I would see that as that every function , by default , is simply defined as having value 'err' at point 'err'
<xkb>
stack overflow
<MegaWatS>
which doesnt really seem ugly to me :/
<xkb>
anyway.. the proffessor im working for thinks it is ugly :) Thus I need to think the same.. otherwise it would be a very short research project :)
<MegaWatS>
i see :)
<MegaWatS>
which university are you working at?
<xkb>
on 2 actually
<xkb>
Technische Universiteit Eindhoven
<xkb>
and the Katholieke universiteit Nijmegen
<xkb>
both in the Netherlands
<MegaWatS>
i see :)
<MegaWatS>
oh I just notice I'm saying that a lot right niow :p
<xkb>
lol!
<xkb>
i see :)
<MegaWatS>
X)
<xkb>
unfortunately I also have to finish several other projects.. and those take up way to much time
<MegaWatS>
hehe
<MegaWatS>
well my (personal, spare-time) projects always end up in nirvana when my interests start to shift and I always start something new without finishing what I started first
<xkb>
LOL! thats my problem exactly
<xkb>
very hard if you need to finish a 6 months project
<MegaWatS>
,/
<MegaWatS>
hm I think Ill go look for something to eat :]
<xkb>
good idea
thierry has quit [Read error: 110 (Connection timed out)]
TimFreeman has joined #ocaml
<MegaWatS>
hi
<pnou>
hi
<pnou>
brb
pnou has quit ["Pas de bras, pas de quit."]
pnou has joined #ocaml
TachYon25 has joined #ocaml
minddog has joined #ocaml
TachYon25 has quit [Remote closed the connection]
TimFreeman has left #ocaml []
SYStems has joined #ocaml
minddog has left #ocaml []
<SYStems>
i think it fukkin irritating that ocaml use different operators for int then for float + vs +. , this total lack of operator overload(or overlaod of any kind) will it be fixed in future versions
<MegaWatS>
I don't think so
<MegaWatS>
you can redefine the operators locally if you need to do lots of floating-point arithmetic in a part of your program, like
<MegaWatS>
let ( + ) = ( +. ) and ( - ) = ( -. ) and ( * ) = ( *. ) and ( / ) = ( /. ) in ...
<SYStems>
ocaml gains its speed from this lack of oepration overload and static typing
<MegaWatS>
actually the lack of operator overloading has nothing to do with its speed
<MegaWatS>
C++ can do overloading, and still can compile basic arithmetic operations efficiently
<MegaWatS>
ocaml doesn't have overloading because it is incompatible with type inferencing
<MegaWatS>
and static typing is a good thing, exactly because it a) catches errors and b) makes the compiled code more efficient
<pnou>
SYStems: did you try gcaml, caml with overloading?
<SYStems>
no i am just beginning ocaml
<lodda>
hmm..what kind of programming language is it?
<SYStems>
but it struck me as iritating to have + and +.
<MegaWatS>
functional, statically-typed, with automatic type inference
<SYStems>
ocaml is also , or should be good because its OO , imperative and functional
<SYStems>
i prefer that type of langs
<SYStems>
and its also french so that kinda makes more sexy
<SYStems>
:P
<MegaWatS>
lol
<lodda>
object oriented, hmm, i like the thinking of OO, but i hate reading it/writing it. i prefer C
<lodda>
french LoL
<MegaWatS>
but I agree its good ... even though its french ( *ducks* )
<MegaWatS>
:p
<pnou>
grrrrr :)
<lodda>
so it is gay ;)
<MegaWatS>
well ... it "surrenders" easily (dont ask me what I mean with THAT, I don't know either :p)
<MegaWatS>
lodda, you don't HAVE to do oo in ocaml
<MegaWatS>
basically it is a functional pl first
<MegaWatS>
and object-oriented second
<SYStems>
langs are not gay, ppl are
<SYStems>
are you gay lodda
<MegaWatS>
well I'm not quite sure about that
<SYStems>
I was kinda hoping to learn Ocaml as a second lang beside python
<MegaWatS>
intercal seems to be quite "gay" to me ....
<SYStems>
but learning python actually is taking more time then i thought
<MegaWatS>
hmm
<MegaWatS>
I don't know much python but what I've seen of it so far seemed pretty easy
<SYStems>
python is easy , but programming is not so easy
<MegaWatS>
I would suspect ocaml to be quite a bit more difficult
<SYStems>
I am using python to learn programming
<MegaWatS>
yes that of course, programming is never easy :>
<SYStems>
I like the ideas behing functional programming
<SYStems>
python functional features are the things i like the most in it
<SYStems>
so i thought ocaml might introduce me to more functional thinking
<MegaWatS>
yeah its pretty cool, but with pragmatism on modern machines in mind, it can only go so far .... which is why I like prefer functional/imperative languages like ocaml to "pure" functional languages like haskell and clean
<SYStems>
and its fast, so it will also be useful , python drawback is speed
<SYStems>
i prefer multi paradigms langs too , makes more sense to add a new paradigms to ur thinking then replacing it with another one
<SYStems>
python is very good at implement multi paradigms
<MegaWatS>
well most speed problems in applications are more of a problem with the algorithm and/or not taking advantage of the right fast library routine than anything else
<MegaWatS>
it's true, the ocaml native-code compiler produces fast code, but these kinds of concerns only really are of interest in very few, specialized problem domains
<SYStems>
python is dynamic and interpreted , i doubt it will ever be as fast as static compiled langs
<MegaWatS>
yes of course
<SYStems>
but am not very knowlegeable so i could be wrong technically
<MegaWatS>
but if you know what you do, you can still get lots of speed out of interpreted languages if you know what you're doing
<SYStems>
i should know, or reach that level of knowledge
<MegaWatS>
python in particular with its large standard library has often ways of doing things simply by calling the right combination of built-in functions - which are very fast
<SYStems>
yes and things like psyco try to make it faster
<SYStems>
but i dont really understand what psyco is
<SYStems>
it too technical for me
<SYStems>
above my level of knowledge
<MegaWatS>
well I don't know either, as I said I only know very little about python, I was talking very generally and only using that as an example :)
<SYStems>
well python is worth knowing
TachYon25 has joined #ocaml
<MegaWatS>
generally, when you're doing things right, except for in very few special cases you're going to get "enough" speed out of your programs
<SYStems>
its the best there is actually
<MegaWatS>
well it would be one of the next languages I'd learn but it doesn't really have anything to offer me to invest that sort of effort to get into it any deeper
<SYStems>
what do you intend to build
<SYStems>
I am learning programming to build a web application
<MegaWatS>
well I currently do not have any special, big program
<SYStems>
I too, don't
<SYStems>
I just have the idea
<MegaWatS>
yes for web applications I guess python should be approporiate, or so I heard .... but this isn't really the area I interest myself in
<SYStems>
and learning to gain the technical knowledge to built it
lodda has left #ocaml []
<SYStems>
what are you into
<MegaWatS>
lots of things :)
<SYStems>
like ?
<MegaWatS>
mainly compiler construction and graphics
<SYStems>
I dont think an interpreted lang should be use to build compilers
<MegaWatS>
where the former is what explains my interest in ocaml because its really the area where ml-like languages shine the most
<SYStems>
i heard so too
<MegaWatS>
apart from that I don't see how that applies here - why?
<SYStems>
why what?
<MegaWatS>
[17:22:55] <SYStems> I dont think an interpreted lang should be use to build compilers
<SYStems>
oops
<SYStems>
i meant should not be used
<MegaWatS>
so what you meant was that you think interpreted languages might be used for compiler building?
<SYStems>
I really dont know all what goes behind the scene to make my source transfor into IO and executed by the computer
<SYStems>
I dont know any of it
<MegaWatS>
i see
<MegaWatS>
well actually it's quite simple :)
<MegaWatS>
the computer itself only knows of bytes - it's memory is just one large string of bytes - and it looks at these bytes one by one, and, depending on their value, performs certain tasks
<MegaWatS>
that's what's called machine code
<MegaWatS>
I'm sure you've heard of that now?
Good^2B^Free has joined #ocaml
<MegaWatS>
hi
SYStems has quit [Killed (NickServ (Nickname Enforcement))]
<MegaWatS>
:/
<Good^2B^Free>
yes am back
<Good^2B^Free>
i was disconneted
<MegaWatS>
oh btw this server has nickserv? good
<Good^2B^Free>
so .... do you know where can i download a paper that explain it
<MegaWatS>
explains what?
Good^2B^Free is now known as SYStems
<SYStems>
how code ----> to machine code ----> to IO
<MegaWatS>
what do you mean by "to IO"?
<SYStems>
binary
<MegaWatS>
machine code is in binary :)
<MegaWatS>
wait
<SYStems>
is it ?
<MegaWatS>
this is what I said after the last thing you said
<MegaWatS>
[17:24:58] <SYStems> I dont know any of it
<MegaWatS>
[17:25:05] <MegaWatS> i see
<MegaWatS>
[17:25:11] <MegaWatS> well actually it's quite simple :)
<MegaWatS>
[17:25:51] <MegaWatS> the computer itself only knows of bytes - it's memory is just one large string of bytes - and it looks at these bytes one by one, and, depending on their value, performs certain tasks
<MegaWatS>
[17:26:03] <MegaWatS> that's what's called machine code
<MegaWatS>
[17:26:12] <MegaWatS> I'm sure you've heard of that now?
<SYStems>
so how do u wrint if then else statement in machine code
<MegaWatS>
well binary is just a way of representing numbers you know
<SYStems>
how to you write loops
<MegaWatS>
hehe thats actually quite complicated
<SYStems>
objects
<MegaWatS>
you can download the x86 specs from intels hp :)
<MegaWatS>
but to explain it shortly
<MegaWatS>
the computer doesn't know anything about objects
<MegaWatS>
it operates on this one, huge array of bytes
<MegaWatS>
image computer memory as eg declared like this: val comp_mem : byte array
<MegaWatS>
where a byte is an integer from range 0 .. 255
<MegaWatS>
now in these bytes all kinds of data structures may be encoded
<MegaWatS>
for example, a string
<MegaWatS>
might be encoded as a series of consecutive bytes
<MegaWatS>
which consist of the ANSI code of the character
<MegaWatS>
and a final 0-byte
<MegaWatS>
eg comp_mem.(102309) might be 65, which is the character 'A', and so forth
<MegaWatS>
and finally comp_mem.(102321) might be zero to mark the end of the string
<MegaWatS>
also encoded can be program code - machine code
<MegaWatS>
this is specific to the CPU
<MegaWatS>
the x86 architecture, for example, is a specific way to encode programs in strings of bytes, and it is the one that intel and amd cpu's understand
<MegaWatS>
an infinite loop, for example, is represented by the two bytes 0EBH and 0FEH
<MegaWatS>
this machine code, however, is pretty primitive
<MegaWatS>
there are no statements or values or such things .... it can only perform simple operations on bytes, which it takes from this one, large array
<MegaWatS>
it is made up of instructions, which are read sequentially from the memory, and then each one in order is performed; and they usually have a side-effect on the memory "array" or the few, built-in variables which are called registers
<MegaWatS>
you have to tell me if I'm boring you or going too fast or anything :)
<MegaWatS>
:[
<pnou>
lol
<MegaWatS>
:)
<MegaWatS>
whats so 'lol' about it? :|
<pnou>
excuse me :/
<MegaWatS>
no I'm just asking
SYStems has quit [Connection timed out]
<pnou>
the fact that you are asking if you are boring us
<pnou>
i found it funny :)
<MegaWatS>
hm well I was trying to explain something to systems and I didn't know his exact level of knowledge, so I thought I asked if I was only telling him things he already knew
<pnou>
yes i didn't say that was strange or silly, just funny :)
<MegaWatS>
:p
SYStems has joined #ocaml
<MegaWatS>
damn right now I'm having to write my own wrapper for libjpeg just because camlimages can't read images from non-files :/
<SYStems>
sowwy megawats i got disconneted again
<MegaWatS>
re
<SYStems>
we have waiting call, so if someone calls i get cut off the net
<MegaWatS>
)_8
<SYStems>
:)
bryan has joined #ocaml
<MegaWatS>
damn I really hate writing a wrapper for libjpeg, it's a real mess to make this source / destination / error manager stuff work correctly with the transition into caml B[
<SYStems>
bye bye megawats
<SYStems>
have fun coding
<SYStems>
:)
<SYStems>
omcalians for ever :P
<SYStems>
and pythoneers as well
<MegaWatS>
cu
SYStems has left #ocaml []
<MegaWatS>
and there isn't even code in camlimages I can usefully cannibalize for my purposes
<MegaWatS>
they simply use C stdio I/O for reading and writing from/to files :|
* gl
is away: I'm busy
olczyk has joined #ocaml
<olczyk>
Can anyone show a simple program that demonstrates the advantage of higher order functions.
<smkl>
how simple?
<olczyk>
Maybe 1K lines. What I *don't* want to see is 10K lines.
<olczyk>
When you have a very complicated program there are a lot of factors and it's not always clear
<olczyk>
what made a major difference.
<olczyk>
But not so simple to be trivial.
<mrvn_>
olczyk: List.iter, List.map, ...
<mrvn_>
Or is that to trivial?
<olczyk>
To trivial. Something that demostrates how a mindset of using hof gives an advantage.
<olczyk>
It doesn't have to be your code. An existing program. Just something that is so complex I lose the forest for the trees.
<mrvn_>
But it is that simple. List.iter, List.map and List.fold_??? are very powerfull.
<mrvn_>
Anything that uses callbacks.
<olczyk>
What does flod_ do?
<olczyk>
Sorry fold_?
<smkl>
let sum = List.fold_left (+) 0
<olczyk>
But there is really no advantage to this. Most programming languages/systems do something like
<olczyk>
callbacks.
<mrvn_>
# let list = [1;2;3];;
<mrvn_>
val list : int list = [1; 2; 3]
<mrvn_>
# List.fold_left (fun x y -> x + y) 0 list;;
<mrvn_>
- : int = 6
<MegaWatS>
in general, a folding function applies the argument function to each argument in a list, and an "accumulator" value which is the previous result
<MegaWatS>
so
<MegaWatS>
fold f [a;b;c;d] start_val is (f a (f b (f c (f d start_val))))
<MegaWatS>
the argument function can be thought of as a binary "addition" operator
<MegaWatS>
then fold "sums" the list, using that "addition" operation
<MegaWatS>
because this kind of structure occurs often in programs, it is very useful
<mrvn_>
olczyk: for sort or maps and hashes a higher level function is also usefull.
gl has quit [No route to host]
gl has joined #ocaml
<mrvn_>
You can write a sort function that takes a comparison function and a list and sorts that.
<smkl>
generally, hofs can be used as simple objects ... most of the time thay are easier to create and use
<mrvn_>
In other languages you can only sort types that can be compared directly. With hofs you can make the comparison a parameter.
<olczyk>
But I have qsort in C which already does that.
<mrvn_>
hof is nothing special for ocaml, it just more natural to use.
<mrvn_>
olczyk: Features you don't have in C are currying and abstract types.
<smkl>
if you have functors, you can sort of simulate higher-order functions
xkb has quit [Read error: 104 (Connection reset by peer)]
<olczyk>
I ask because people keep telling me that hof are an advantage over imperative languages.
<mrvn_>
olczyk: They are but most languages have them in some form.
<mrvn_>
olczyk: C/C++ has function pointers.
<olczyk>
So it's just people who never learned imperative languages very well. Then they go to a FP and learn everything that they should have in the imperative language,
<mrvn_>
olczyk: But did you ever see a double (*foo(double (int )))(double )
<mrvn_>
in C?
<olczyk>
and naively mistake them as advantages?
<MegaWatS>
olczyk
<MegaWatS>
there IS a real difference
<MegaWatS>
closures
<MegaWatS>
you can't do a
<MegaWatS>
let foo bar = fun baz -> baz bar
<MegaWatS>
in C++
<MegaWatS>
for example
<MegaWatS>
you'll have to use a class
<MegaWatS>
like
<mrvn_>
olczyk: In most imperative languages you can't make unnamed functions, closures.
<MegaWatS>
its not even about unnamed functions
<MegaWatS>
but closures encapsulate the whole environment
<mrvn_>
MegaWatS: Yes you can, but with pointers.
<MegaWatS>
where the function was defined
<MegaWatS>
it is about lexical scoping
<MegaWatS>
yes that was what I meant
<mrvn_>
MegaWatS: and some extra code.
<MegaWatS>
you have to explicitly code it
<MegaWatS>
ie
<MegaWatS>
you cant do it
<MegaWatS>
youll have to provide the mechanism yourself
<mrvn_>
olczyk: let foo x = x (); is a lot easier.
<mrvn_>
olczyk: Do you know what currying is?
<olczyk>
Yeas.
<Dybbuk>
mrvn_: I don't. :)
<mrvn_>
Its a lot of work to simulate that in C/C++
<mrvn_>
Dybbuk: let foo x y = ....; let bla = foo 1;
<olczyk>
Hmmm.
<MegaWatS>
ok i have a moment time
<mrvn_>
Dybbuk: foo x y is transformed to let foo = function x -> function y -> ...
<MegaWatS>
olczyk
<olczyk>
It's longer.
<MegaWatS>
the important thing is capturing the environment
<MegaWatS>
ie
<MegaWatS>
you can define functions which depend on the environment
<MegaWatS>
the example I posted above
<MegaWatS>
[19:53:57] <MegaWatS> let foo bar = fun baz -> baz bar
<MegaWatS>
foo returns a different function
<MegaWatS>
depending on it's argument
<MegaWatS>
call foo ( + ) and it returns a function which applies it's argument to ( + )
<MegaWatS>
call foo 17 and it returns a function which applies it's argument to 17
<MegaWatS>
etc
<olczyk>
Put arguments in the constructor of a function object.
<Dybbuk>
Ahhh, that's currying?
<MegaWatS>
this is because you can use all variables which are visible at the point where the function was defined
<MegaWatS>
olczyk, OF COURSE you can simulate it
<MegaWatS>
thats not the point :)
<MegaWatS>
all the languages we discuss are turing-complete, ... or at least I hope so:>
<MegaWatS>
the point is that you can't do the same thing - you have to emulate the behaviour
<MegaWatS>
and when you have, for example, LOTS of variables visible in the environment where you define a function,
<MegaWatS>
passing those with a constructor might become a bit tedious, no?
<MegaWatS>
well im afk again brb :)
<mrvn_>
In C this would something like this: int (*foo(int x))(int) { return struct { int operator()(int (*x(int))){return x(y);}; int y = x; }; }
<mrvn_>
Except that you can't write it quite like that.
<mrvn_>
And you have to rewrite it again and again for every simple variation of the theme.
<mrvn_>
The difference is that you need one structure definition for a sort function, one for the foo function, one for a blub function,... You can't reuse the structure.
<mrvn_>
And the structure depends on the function you want to pass to foo or sort.
<mrvn_>
In ocaml you just write "let foo bar = function baz = baz bar" and stuff that into a module. You can reuse it again and again without changing it.
<mrvn_>
Dybbuk: basically yes.
<mrvn_>
olczyk: did you follow so far?
TachYon25 has quit [Remote closed the connection]
gl has quit [Read error: 113 (No route to host)]
gl has joined #ocaml
<mrvn_>
let make_task f min max =
<mrvn_>
let rec t x tasks =
<mrvn_>
f x;
<mrvn_>
next (if x < max then (add (t (x + 1)) tasks) else tasks)
<mrvn_>
in t min;;
<mrvn_>
ups, sorry
<mrvn_>
olczyk: Still want an example with higher level functions?
* mrvn_
has a little multitasking example here.
olczyk has quit [Read error: 113 (No route to host)]
<mrvn_>
there goes nothing
<MegaWatS>
:/
two-face has joined #ocaml
<two-face>
yo
<gl>
yo
<pnou>
yop
* gl
is back (gone 00:56:12)
<pnou>
From: Thaddeus L Olczyk <olczyk@interaccess.com>
<pnou>
Someone just advocated the advantages of using higher order functions.
<pnou>
I'm relatively new to FP but do want to see if it works. So I asked
<pnou>
for examples. What I got instead were slogans and one really lame
<pnou>
example which shows nothing.
<pnou>
i think he is talking about us :)
<two-face>
:)
<MegaWatS>
....
<MegaWatS>
is there a better wrapper for libjpeg for ocaml than the one in camlimages available somewhere?
<MegaWatS>
I hope they aren't starting a huge flamewar about that post from olczyk now :/
<two-face>
when was it posted?
<MegaWatS>
I dunno
<MegaWatS>
[21:19:45] <MegaWatS> is there a better wrapper for libjpeg for ocaml than the one in camlimages available somewhere? <-- ? :|
<two-face>
MegaWatS: STFH !
<MegaWatS>
?
<two-face>
Search The Fucking Humps :))
<MegaWatS>
I did
<MegaWatS>
and found nothing
<two-face>
and ?
<two-face>
so there isn't anything
<MegaWatS>
and thats why I'm asking here
<MegaWatS>
hmm :|
<pnou>
Newsgroups: comp.lang.ml
<pnou>
Date: 23 Sep 2002 17:34:44 GMT
<two-face>
why is camlimages bad?
<MegaWatS>
I didn't know every last single ocaml programmer posted all the stuff they write to the humps :)
<MegaWatS>
because it doesn't support reading from something else than a file
<MegaWatS>
I have a bunch of zipped jpeg files as resources for my application
<MegaWatS>
well, a WHOLE bunch ... several zips with several dozen megabytes and hundreds of images each
<two-face>
so you'll have to write a binding for libjpeg then
<MegaWatS>
thats what I was trying to avoid B|
<two-face>
it shouldn't be hard to do
<MegaWatS>
well
<MegaWatS>
its not as easy as it sounds
<MegaWatS>
to handle input / output managers and error handling cleanly
<two-face>
ah
<two-face>
well
<MegaWatS>
but I think I'll just write one only for the special cases I need
<two-face>
you can just adapt camlimages
<MegaWatS>
well they just use C's FILE* I/O
<MegaWatS>
so there's really not much code which I could cannibalize
<MegaWatS>
from there
<two-face>
hmm
<MegaWatS>
but I will live, I just think it's strange that they make such a library such as camlimages so limited
<two-face>
well, they're waiting for someone to tell them :)
<MegaWatS>
when it's supposed to be written to really solve that problem once and for all, that something basic like getting the image from some arbitrary, non-file stream source is not supported
MegaWatS is now known as literatiWatS
<mrvn_>
abstract it.
<two-face>
hello Goswin
<mrvn_>
Hi Jerome
<two-face>
how going?
<mrvn_>
its ok.
gl has quit [Read error: 113 (No route to host)]
<two-face>
and mldonkey?
gl has joined #ocaml
<mrvn_>
Still has a license problem with its gpattern files.
<two-face>
ah, I know that, I guess it is QPL
<mrvn_>
Yep, thats the problem.
<two-face>
I hope it won't change otherwise I'm in trouble next
<mrvn_>
why?
<two-face>
Because I'm packaing a fully QPL project, Cameleon
<two-face>
integrating gpattern
<mrvn_>
I'm thinking about kicking gpattern out. Its one class that can probably be rewritten easily under GPL.
<two-face>
well, it is unfortunate
<two-face>
QPl is the chosen licence at INRIA
<mrvn_>
Its a bad idea for a library.
<mrvn_>
Even QT is dual licensed.
<two-face>
you could propose a dual licensing
<mrvn_>
method on_select (d:'a) = ()
<mrvn_>
What does that do?
<mrvn_>
Just eat up d and do nothing?
<two-face>
think so
<two-face>
returns unit
<mrvn_>
What for? Its not virtual and it doesn't inherit anything.
<two-face>
hmm
<two-face>
is it from the mldonkey code?
<mrvn_>
Yes.
<two-face>
what file precisely?
<mrvn_>
Looks like it had been used for something but then stripped down to ().
<mrvn_>
gpattern/gpattern.ml
<two-face>
ok
<two-face>
the class is virtual
<mrvn_>
Can you make a function virtual and assign code to it at the same time?
<two-face>
yes you can
<two-face>
ah
<two-face>
the clas is virtual
<two-face>
the class is virtual but a method is not necessarily virtual
<mrvn_>
The class yes but not the method.
<two-face>
yes
<mrvn_>
# class virtual foo = object method virtual f x = () end;;
<mrvn_>
Syntax error
<mrvn_>
The x is underlined.
<literatiWatS>
well its a syntax error
<literatiWatS>
you define a virtual method
<literatiWatS>
which you're not supposed to
<literatiWatS>
the correct synatx for declaring a virtual method is
<literatiWatS>
method virtual foo : type
<literatiWatS>
eg
<literatiWatS>
method virtual f : int -> unit
<mrvn_>
I want it to be virtual but still supply a default function.
<mrvn_>
So you can overload it but you don't have to.
<literatiWatS>
all methods are by default virtual in that sense
<literatiWatS>
a virtual method in ocaml refers to one that has no definition
<literatiWatS>
as opposed to C++
<literatiWatS>
where it refers to one which may be dynamically overloaded
<literatiWatS>
all methods in ocaml are virtual in that sense
<mrvn_>
IC.
<mrvn_>
Doesn't a virtual method have to be looked up during runtime while a static one can be looked up during compile?
<literatiWatS>
I don't know exactly how ocaml implements classes
<literatiWatS>
but I think method dispatch in ocaml is a bit more complicated than in C++ anyway
<literatiWatS>
and not really the fastest thing in the language, either
<two-face>
literatiWatS: which is true in every multiparadigm language
<mrvn_>
If every method uses a indirection thats bound to be slow.
<literatiWatS>
indirect calling is actually relatively inexpensive on modern cpu's
<mrvn_>
Thats the nice thing in C++. The compiler knows what needs an indirections and what not and can inline functions or directly jump to the right ones.
<two-face>
i'm not sure if the new in ocaml is implemented the same way as the new in C++
<literatiWatS>
I don't think it is
malc has joined #ocaml
<mrvn_>
literatiWatS: You make a load address (2-80 cycles) and then a jump to that.
<two-face>
hi malc
<malc>
two-face
<mrvn_>
If you get a cache miss there your realy screwed.
<two-face>
inlining is not always a good thing
<literatiWatS>
of course, but if you get a cache miss that means that the object was not already in the cache
<literatiWatS>
and the method code most probably needs to access the object anyway
<literatiWatS>
so it just puts that cache miss to an a bit earlier point in time
<mrvn_>
literatiWatS: Most small C++ classes have no virtual table.
<mrvn_>
Which is at a different address than the classes values.
<mrvn_>
You get one miss for the virtual table, one for the code and one for the data on a new class.
<malc>
erm..
<malc>
only compiler falls under QPL
<two-face>
yep
gl has quit ["dust to dust, ashes to ashes..."]
gl has joined #ocaml
<mrvn_>
malc: ??
<literatiWatS>
as I said , i don't think ocaml objects work the same way ie with virtual tables
<malc>
mrvn_: !!
<literatiWatS>
anyway, method dispatch is a bit more complicated and costly in ocaml
<mrvn_>
malc: what compiler?
<malc>
mrvn_: Intercal
<malc>
blah
<mrvn_>
literatiWatS: Probably.
<mrvn_>
literatiWatS: Knowing what functions can be overloaded should help the compiler.
<mrvn_>
literatiWatS: Too bad they didn't design it that way.
<literatiWatS>
I really think - if at all -that should be something the compiler determines on its own
<literatiWatS>
it really puts too much burden on the programmer
<mrvn_>
literatiWatS: It can't.
<literatiWatS>
especially when we're talking about oop
<literatiWatS>
you can't know in advance what methods someone might want to replace later
<mrvn_>
When you compile a class you never know if anyone might inherit that later and overload a function.
<literatiWatS>
it can't? why can't it?
<literatiWatS>
yes you do
<literatiWatS>
when you have all the source code of the whole program available, you do
<mrvn_>
How? That class can be written 3 years later.
<literatiWatS>
?
<literatiWatS>
so what?
<mrvn_>
You would add a dependencie between a classes implementation and what it inherits, a circular one at that.
<literatiWatS>
I don't see that
<mrvn_>
A second ml file should not change the way the first is compiled
<literatiWatS>
you simply have to look at all the classes that inherit a specific class, and look which methods are overloaded
<literatiWatS>
that can be solved by a specific linkage format
<mrvn_>
So class foo inherits class bla and overloads a function. That means foo.ml depends on bla.ml, but also bla.ml depends on foo.ml.
<mrvn_>
I you remove the overloading in bla foo must be recompiled.
<mrvn_>
bla.mli wouldn't chnage though.
<literatiWatS>
[22:15:02] <literatiWatS> that can be solved by a specific linkage format
<mrvn_>
evil
<literatiWatS>
i dont think so :)
<literatiWatS>
a good oop-specific linkage format should support that
<mrvn_>
What about stuff thats already being linked. .oO( Does ocaml have libraries as such? )
<literatiWatS>
but thats really besides the point here, ocaml (to the best of my knowledge) doesn't do anything of the sort
<literatiWatS>
but ocaml isn't a oop centric language, either
<mrvn_>
A linkage format wouldn't realy work. You would have cases where the additional info required increases exponentially.
foo__ has joined #ocaml
<two-face>
mrvn_: what do you mean?
gl has quit [Killed (NickServ (Ghost: foo__!~foo@du-212-17.nat.adsl.freesurf.fr))]
foo__ is now known as gl
<mrvn_>
two-face: You could have a list of classes each inheriting the one before and adding a function. Each combination of overloadable and not overloadable would have to be linked in.
<literatiWatS>
um no
<mrvn_>
Thats 2^(number of classes) many interfaces.
<literatiWatS>
you don't have to have every possible combination of possible targets there either
<literatiWatS>
for example
<literatiWatS>
object A calls function "foo"
<literatiWatS>
you don't have one iomplementation of object A for each possible adress opf function "foo" either
<mrvn_>
You could default to all overloadable if its not a simple case. But then your back to the slower mode.
<literatiWatS>
but the linker knows how to change the code to make the correct call
<mrvn_>
literatiWatS: Would be much more complicated and I don't think worth it.
<literatiWatS>
compilers are a complicated matter
<literatiWatS>
I think that would be the least of the troubles a compiler implementor would go to :)
<mrvn_>
There are link time optimizer for C/C++ and even with such a simple calling convention the have to reschedule everything.
<mrvn_>
You have to implement it for every arch again. Thats makes it a lot of work.
<literatiWatS>
?
<literatiWatS>
I dont get what arches you're talking about
<literatiWatS>
and of course some kind of rescheduling, to make it really efficient, would be nice to have in such a linker :)
<mrvn_>
you would have to implement your own linker.
<literatiWatS>
that is a given
<mrvn_>
Most compilers don't bother
<literatiWatS>
C object file format isnt really very good for anything but, well, languages like C
<mrvn_>
Far too much work.
<literatiWatS>
well ocaml does for example :)
<literatiWatS>
and for much smaller gains
<literatiWatS>
"only" to enforce type safety during linkage
<two-face>
you can load bytecode dynamically
<literatiWatS>
yes I know that
<malc>
you can load anything dynamically
<literatiWatS>
I don't see how it pertains to this discussion though?
<mrvn_>
Anyway, how do you prevent someone to overload one of your functions and wreck havock with your class?
<literatiWatS>
afaik there is no possibility to dynamically link native-code compiled modules in ocaml right now
<two-face>
malc: not native ocaml code
<malc>
two-face: wanna bet?
<two-face>
malc: does your patch do that?
<malc>
yes
<literatiWatS>
[22:27:16] <mrvn_> Anyway, how do you prevent someone to overload one of your functions and wreck havock with your class? <--- erm as I said, I don't assume either way, the compiler only puts information for the linker into the object file that a call to a method happens there into the object file
<literatiWatS>
and the linker puts in the correct code
<two-face>
malc: is it safe?
<malc>
two-face: in what sense
<literatiWatS>
depending on whether there is an overloading of that function anywhere
<literatiWatS>
type-safe
<two-face>
malc: the bytecode can be checked when loaded, not the nativecode
<literatiWatS>
if the interface is checked against what the importing module expects
<mrvn_>
literatiWatS: I meant now.
<literatiWatS>
is what he means, I guess
<literatiWatS>
[22:29:27] <mrvn_> literatiWatS: I meant now. <-- now?
<malc>
two-face: i cant be arsed to add checking, you have to carry around cmis for that, no thank you
<two-face>
malc: well, ocaml is all about safety, isn't it?
<malc>
two-face: you are DYNAMICALY loading something.. and expect static typing to work.. ahem
<malc>
checking dynlink provides is superficial
<two-face>
malc: maybe md5 or something
<malc>
last thing i wanted is to dictate any kind of checking
<malc>
im not competent enough for that
<two-face>
right
<literatiWatS>
mrvn_: what did you mean with that - now?
<mrvn_>
literatiWatS: class foo = object method f = 0 end;; class bla = object inherit foo method f = 1 end;;
<literatiWatS>
yes
<literatiWatS>
what about it?
<mrvn_>
How do I prevent bla from overloading f?
<literatiWatS>
why would you want to?
<mrvn_>
To make sure it does what it does.
<two-face>
malc: dynloading is probably not the best thing to do anyway
<literatiWatS>
well there is no mechanism for that in ocaml
<literatiWatS>
simply don't overload it :)
<mrvn_>
Ok, so I can stop looking.
<malc>
two-face: maybe
<mrvn_>
C++ differentiates that more because of the different calling styles.
<literatiWatS>
what you CAN do is make the method private
<literatiWatS>
or declare it as a locally bound variable, like class foo = let bla = ... in object ... end
<mrvn_>
Then it would be private.
<literatiWatS>
yes as I said :)
<two-face>
malc: notto mention the DLL hell problems
<malc>
two-face: do you think that after spending tons of time trying to making it all work, i will agree with remarks like this?
<two-face>
malc: what i am suposed to answer?
<malc>
nothing it was purely rethorical
<two-face>
you think i'm clueless?
<malc>
yes
<two-face>
alright
<literatiWatS>
good that we've got that cleared up now, right?
literatiWatS is now known as MegaWatS
gl has quit [Read error: 113 (No route to host)]
gl has joined #ocaml
<malc>
nope
<two-face>
i feel offended
<malc>
i feel less benevolent than usual, and that hurts
<two-face>
that's not the idea i have of releationship, i'm afraid
<MegaWatS>
8[
<malc>
two-face: to put it in your own way 'what was i supposed to answer?'
<two-face>
malc: i won't fight
<two-face>
*shrug*
<malc>
lets all hug now
<MegaWatS>
{{{everybody}}}
<MegaWatS>
that good?
<malc>
Ja
<MegaWatS>
:)
<malc>
two-face: no hug?
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
<mrvn_>
List.iter hug [:EVERYBODY:];;
<malc>
mrvn_: for the love of god, drop this ;;
<MegaWatS>
well maybe he just entered it into the toplevel :)