structured has quit [Read error: 110 (Connection timed out)]
Waleee has quit []
<palomer>
because the exception never gets to the toplevel
<palomer>
lablgtk catches it
<palomer>
well, it chatches Failure
<palomer>
catches
<palomer>
maybe If I try something else
<palomer>
yeah
<palomer>
it catches everything
<palomer>
and just prints it out
<palomer>
like this In callback for signal key_press_event, uncaught exception: Top.Bar("shoom")
<tsuyoshi>
so.. load it into the debugger, set a breakpoint on raise
<tsuyoshi>
then you can get your backtrace
<orbitz>
uhh
<orbitz>
uncaught
<orbitz>
are you runing with stack traces turned on?
<palomer>
that means compiling with -g and running with -b right?
<orbitz>
are you native or bytecode?
<palomer>
bytecode
jlouis has quit [Read error: 110 (Connection timed out)]
m3ga has joined #ocaml
m3ga has quit [Client Quit]
<palomer>
tsuyoshi: how do I set a breakpoint on raise?
netx has joined #ocaml
<palomer>
orbitz, it doesn't reach the toplevel though
<tsuyoshi>
I don't know.. never really used the debugger
<palomer>
I don't think you can
<tsuyoshi>
that would be really weird
<tsuyoshi>
unless maybe you need to compile the standard library with debugging information
<palomer>
break raise doesn't work
<palomer>
oh wait
<palomer>
maybe I need to qualify it
<palomer>
Pervasives.raise
<palomer>
nope
<palomer>
doesn't work
<palomer>
break Pervasives.raise
<palomer>
Breakpoint 1 at 3920 : file pervasives.ml, line 23, characters 21-46
<palomer>
but then when the exception is raise the program just borks
mfp has quit [Read error: 110 (Connection timed out)]
<palomer>
the debugger won't accept any more input
<palomer>
yeah, once my program starts running ocamldebug doesn't respond
<tsuyoshi>
maybe GtkSignal.user_handler is what you need
mfp has joined #ocaml
<palomer>
taht's in lablgtk?
<palomer>
can't find it
<palomer>
found it
<palomer>
but what can I do with the exception?
<tsuyoshi>
I remember that I ran into this myself before.. I think I ended up just putting lots of printfs in the code to find where the exception was getting raised
<palomer>
yeah
<palomer>
that's what I'm doing
<palomer>
oh well, gotta continue
<palomer>
no stack traces and my omake is screwed
<palomer>
what's going on!
<tsuyoshi>
there ought to be a way to get a backtrace.. maybe if you modify the lablgtk code to quit trapping all the exceptions
<tsuyoshi>
I think they put that in there because if you catch the exception above the gtk mainloop bad things happen
<tsuyoshi>
but if you don't catch it at all it should go to the backtrace and it should be fine
<palomer>
it would crash
<palomer>
which is OK with me!
<palomer>
hrmph
* palomer
wonders how to transform ocamlc -I +lablgtk2 -I /usr/lib/ocaml/3.09.2/extlib extLib.cma -g -o base lablgtk.cma gtkInit.cmo Utilities.ml ... Main.ml into an omakefile
<palomer>
brb
palomer has quit ["Leaving"]
palomer has joined #ocaml
<palomer>
Utilities.cmi depends on: Utilities.ml
<palomer>
Utilities.cmo depends on: Utilities.ml
<palomer>
that's what I get when I try to compile Utilities.ml
<palomer>
OCamlProgram(hello, hello_code Utilities) <--this is what I use
jdrake has joined #ocaml
<palomer>
hrmph
<palomer>
how do I add extlib to my omake?
<palomer>
gord, it works
<palomer>
IT WORKS!
<palomer>
LAWD
<jdrake>
Is lablgtk good enough to make a solid application with?
<palomer>
jdrake, hadn't had a problem with it
<palomer>
(except maybe for the stack traces!)
<palomer>
it's a little hard to debug, but otherwise rock solid
<palomer>
but that'll change with ocaml 3.11
<jdrake>
I have an idea for a CAD program (I have a lot of paperwork to do on the idea first), and I was looking at various languages that might be useful to develop in.
<jdrake>
There is a certain value in the ocaml, sml, haskell type systems. MLton seems to be decently fast, but doesn't have the gtk libraries that ocaml has.
<jdrake>
I would normally pick something like python, but I am unsure about it in a larger application. Same with C.
<palomer>
ocaml has the best libraries out of those
<palomer>
furthermore, it has a bytecode compiler. you can run the bytecode on any operating system that supports it
<palomer>
a nice debugger
<jdrake>
As a bonus I have used ocaml briefly before, so it isn't so bad.
<jdrake>
Right now I am doing some scheme, with the intention of doing some SICP.
mikeX_ has joined #ocaml
<palomer>
SICP is cool
<palomer>
everyone should do it once
<jdrake>
Is there anything special in ocaml 3.10.2 that isn't in .0?
<jdrake>
Special as in something that would be of extreme benefit, and not in waiting till october for the next ubuntu release.
AxleLonghorn has joined #ocaml
AxleLonghorn has left #ocaml []
<palomer>
doesn't seem like it
<palomer>
BUT
<palomer>
ocaml CVS has cool stuff
<palomer>
well, print_backtrace
<palomer>
that's cool enough for me
<jdrake>
CVS is something I won't touch
<jdrake>
Right now I am after minimal effort for use
<palomer>
err, I meant compiling from source
<jdrake>
ubuntu packages are it :-)
<palomer>
but yeah, I understand you
mikeX has quit [Read error: 101 (Network is unreachable)]
<palomer>
well, you better try out all those languages and seeing which one you like best
<palomer>
you might find that each one is best in different situations
<jdrake>
Out of all the languages, I know C the best, and know python the second best.
netx has quit [Read error: 110 (Connection timed out)]
<jdrake>
C would be a nightmare to create something in it.
<palomer>
I don't understand C
* palomer
is off
<jdrake>
I do microcontrollers too :-)
<jdrake>
I also do assembly
<jdrake>
ACtually there was one other area I was curious if ocaml could support: I would like to have some level of scripting (specific extent unknown), and I was wondering if ocaml has anything in particular that might be useful there.
evn has quit [Read error: 104 (Connection reset by peer)]
evn has joined #ocaml
jdrake has quit [Read error: 110 (Connection timed out)]
seafood_ has joined #ocaml
alexyk has joined #ocaml
olleolleolle has joined #ocaml
<palomer>
my program is so beautiful I'm going to cry
<orbitz>
don't get any on me
* palomer
gets it ALL on orbitz
<palomer>
jdrake: maybe some offshoot like F#
coucou747 has joined #ocaml
evn has quit []
olleolleolle has quit [Client Quit]
<palomer>
I was walking in the park
<palomer>
and I was like
<palomer>
"oh no, maybe my code isn't so great"
<palomer>
but I came back here and cried tears of joy
<palomer>
book of genesis, chapter 5, paragraph 3
ikaros has joined #ocaml
alexyk has quit []
coucou747 has quit ["bye ca veut dire tchao en anglais"]
nuncanada has quit ["Leaving"]
<flux>
browsing through Jane St Ocaml Core interfaces.. what's this? val create : ?never_shrink:bool -> ?initial_index:int -> dummy:'a -> unit -> 'a t (* a dummy element is required to satisfy the type-checker and will never be returned *)
<flux>
apparently it stuffs the dummy value into the record it uses
<flux>
I can't understand why
<flux>
ah, probably this why: Array.create new_plength buf.dummy
<flux>
seems a hack to me, anyway
<flux>
I actually would prefer even the Obj.magic -workaround for that :-o
smimou has joined #ocaml
olleolleolle has joined #ocaml
filp has joined #ocaml
ygrek has joined #ocaml
Snark has joined #ocaml
al-maisan has joined #ocaml
<al-maisan>
Hello there!
<al-maisan>
What is the easiest way to join (as in Python) a list of strings?
<al-maisan>
Here's what I mean:
<al-maisan>
>>> '::'.join(["a", "b", "c"])
<al-maisan>
'a::b::c'
<flux>
String.concat "::" ["a"; "b"; "c"]
<al-maisan>
flux: cool! Thanks!
al-maisan has quit [Remote closed the connection]
petchema has quit [Remote closed the connection]
OChameau has joined #ocaml
Yoric[DT] has joined #ocaml
Mr_Awesome has quit ["aunt jemima is the devil!"]
Mr_Awesome has joined #ocaml
Mr_Awesome has quit [Client Quit]
seafood_ has quit []
olleolleolle has left #ocaml []
jlouis has joined #ocaml
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
^florian has joined #ocaml
^florian has quit [Client Quit]
^florian has joined #ocaml
^florian has left #ocaml []
yangsx has quit [Read error: 110 (Connection timed out)]
mikeX_ has quit [Read error: 110 (Connection timed out)]
hkBst has joined #ocaml
jlouis has quit [Remote closed the connection]
rwmjones has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
yminsky_ has joined #ocaml
seafood_ has joined #ocaml
petchema has joined #ocaml
yminsky_ has quit []
coucou747 has joined #ocaml
Yoric[DT] has joined #ocaml
<Yoric[DT]>
hi again
OChameau has quit ["Leaving"]
olleolleolle_ has joined #ocaml
OChameau has joined #ocaml
olleolleolle_ has left #ocaml []
ygrek has quit [Remote closed the connection]
seafood_ has quit [Read error: 110 (Connection timed out)]
al-maisan has joined #ocaml
Snark has quit ["Ex-Chat"]
AxleLonghorn has joined #ocaml
AxleLonghorn has left #ocaml []
<rwmjones>
ok, here's an interesting problem ...
<rwmjones>
got various immutable 'core' structures
<rwmjones>
and plugins which create / act on those structures
<rwmjones>
each plugin would like to attach its own private data to the structures
<rwmjones>
the core doesn't know / want to know about this private data attached
<rwmjones>
so far, using a Hashtbl in the plugin to hash from structure -> private data has worked fine
<rwmjones>
_but_
RobertFischer has joined #ocaml
<rwmjones>
the core sometimes copies these structures (eg. let newstruct = { oldstruct with field = newdata })
<rwmjones>
the problem is that this causes all the private data attached to oldstruct to effectively disappear
<rwmjones>
any ideas how to solve?
<orbitz>
gooood mroning
<flux>
what is 'the core'?
<rwmjones>
flux, it's just the core code, around which plugins live
<flux>
maybe core could be extended to support private data?
<rwmjones>
flux, any idea how?
LordMetroid has joined #ocaml
<rwmjones>
that would be a good idea, but I don't see how to do it
<flux>
which component does the access to the plugins?
<flux>
or do the plugins do the access?
<rwmjones>
the problem is that we can't use type 'a struc { priv : 'a; ... }
<rwmjones>
because then the structures can't be stored in mixed lists
<rwmjones>
the plugins create & access the data structures
<flux>
what kind of operations do the plugins offer?
<flux>
how about using the traditional class -based approach? (or records of closures if you wish)
<rwmjones>
well they do the stuff that can't be generalized in the core!
<orbitz>
a plugin could store it's own data at the module level witha ref
<orbitz>
it's ugly but works?
<rwmjones>
that's how the current impl works (using a hash of structure -> private data)
<rwmjones>
but it doesn't fix the copying problem above
<flux>
I don't think I understand the problem, as I don't see how a plugin could ever lose its data.. it keeps references to it, right?-o
<rwmjones>
but if the core does ... let newstruct = { oldstruct with field = newdata } ... then any private data "attached" (via hashtables) to oldstruct isn't attached to newstruct
<orbitz>
are you saying that the plugin put its data in the 'field' elemetn of teh record?
<flux>
so the hash is from that record to plugin data?
<rwmjones>
no, the plugin attached its data to the oldstruct by doing Hashtbl.add h oldstruct myprivatedata
<rwmjones>
yes
<orbitz>
ohh
<flux>
so any mutation would make it lose the association
<orbitz>
it's kind of hard to give a solid solution without knowing more about your app,but you might need to make it so every update of newstruct happens with a callback
<flux>
how about if you generate unique ids, and put that id into the struct?
<flux>
and the hash would be from that id to the data?
<rwmjones>
yeah, that's a solution, but not pretty :-(
<rwmjones>
I can also mark all the copies
<rwmjones>
however
<rwmjones>
what if the core could see the hashtables? (ie. it has a function to generate them on behalf of the plugins)
<rwmjones>
in fact, it has a function like this:
lordmetroid_ has joined #ocaml
<rwmjones>
val private_data_functions : unit -> ('a -> 'b -> unit) * ('a -> 'b)
<rwmjones>
(* This allows plug-ins to attach their own private data to
<rwmjones>
* the normal plug-in structures (partitions, filesystem, pv, etc.)
<rwmjones>
*)
<rwmjones>
let private_data_functions () =
<rwmjones>
let h = Hashtbl.create 13 in
<rwmjones>
(fun struc data ->
<rwmjones>
Hashtbl.replace h struc data),
<rwmjones>
(fun struc ->
<rwmjones>
try Hashtbl.find h struc
<rwmjones>
with Not_found -> assert false (* internal error in the plug-in *))
<orbitz>
rwmjones: pastebin sir.
lordmetroid_ has quit [Client Quit]
LordMetroid has quit [Connection timed out]
<al-maisan>
Hi there!
<al-maisan>
can somebody point me to an example of pattern matching on records please?
<orbitz>
match {a = 2; b = 3} with {a = x; b = y} -> (x, y)
<al-maisan>
orbitz: thanks !
<orbitz>
match {a = 2; b = 3} with {a = x} -> x;;
<orbitz>
too
<orbitz>
"The pattern { field1 = pattern1 ; . ; fieldn = patternn } matches records that define at least the fields field1 through fieldn, and such that the value associated to fieldi matches the pattern patterni, for i = 1,. , n. The record value can define more fields than field1 .fieldn; the values associated to these extra fields are not taken into account for matching."
* RobertFischer
gets bowled over by rwmjones and his code.
<rwmjones>
type s = { a : string; }
<rwmjones>
# let make () = { a = String.copy "foo" } ;;
<rwmjones>
val make : unit -> s = <fun>
<rwmjones>
# let a = make () ;;
<rwmjones>
val a : s = {a = "foo"}
<rwmjones>
# let b = make () ;;
<rwmjones>
val b : s = {a = "foo"}
<rwmjones>
# a == b ;;
<orbitz>
rwmjones: could you use a pastebin liek i said the first time
<rwmjones>
- : bool = false
<RobertFischer>
Is "==" doing some kind of weird recursive-equals-by-parts?
<RobertFischer>
Seems to be.
<orbitz>
== does not work propa on strings
<orbitz>
use =
<orbitz>
but that'll give you weird error
<orbitz>
"foo" == "foo"
<orbitz>
false
<orbitz>
use =
<orbitz>
it works properlyf or strings
<RobertFischer>
That's because == is referential equality, right?
<orbitz>
i think so
<orbitz>
i alwasy get the two confused coming from other lagnauges
* orbitz
si sued to = doing matches
<rwmjones>
no I'm wondering how the compiler works out that the first structure is completely static, so it doesn't need to generate a fresh one each time
ikaros has quit [Read error: 113 (No route to host)]
<orbitz>
what do you mean?
<RobertFischer>
I don't think it is.
<RobertFischer>
a == 3
ikaros has joined #ocaml
<RobertFischer>
Sorry.
<RobertFischer>
3 == 3
<orbitz>
your code has scrolled away from me (that's wh ywe used pastebins)
<RobertFischer>
So I don't think it's reusing the structure. I think it's just doing equality-by-parts.
<orbitz>
{a=2} == {a=2};; -> bool = false
<RobertFischer>
orbitz: WTF?
<RobertFischer>
# { a = 3} = { a = 3};;
<RobertFischer>
- : bool = true
<orbitz>
we need an ocaml oalbd abot
<hcarty>
orbitz: oalbd abot?
<orbitz>
ocaml lambda bot
<hcarty>
Ah, ok
<RobertFischer>
# {a = 3 } == {a = 3};;
<RobertFischer>
- : bool = false
<RobertFischer>
# { a = 3 } = {a = 3};;
<RobertFischer>
- : bool = true
<hcarty>
There is xavierbot
<hcarty>
But it is apparently not alive at the moment
<orbitz>
is the confusion that rwmjones expects let make () = {a=3};; to construct a new record each time?
nysin has joined #ocaml
<rwmjones>
yes, well, maybe
<rwmjones>
I did wonder if it might
<orbitz>
rwmjones: notice that if you do
<orbitz>
type s = { a : int; }
<orbitz>
(make ()) == (make ());;
<orbitz>
is true
<orbitz>
however
<orbitz>
if you do
<orbitz>
type s = { mutable a : int};;
<orbitz>
it is false
<tsuyoshi>
does the standard say anything about that
<orbitz>
it appears you should use = for comparison
<rwmjones>
I want to use == in this case, see earlier discussions
<orbitz>
tsuyoshi: i'm not sure, i beleive it has to do with how == defines equality
<orbitz>
rwmjones: i'm sorry i missed it. can you restate why?
<rwmjones>
because I want to attach some stuff to the structure, using a map keyed by physical ==
<tsuyoshi>
orbitz: well I'm pretty clear on what == is supposed to do.. just not what constant structures in the code are supposed to do
<orbitz>
tsuyoshi: what is == supposed to do? is it some sort of 'reference' comparison?
<tsuyoshi>
right.. it just compares the pointer
<orbitz>
ok
<tsuyoshi>
= compares everything pointed to
<orbitz>
ok
<tsuyoshi>
if just putting a "mutable" in there changes the behavior.. that's actually kind of annoying
<orbitz>
tsuyoshi: i'm not sure what the ocaml standard says abotu records. i have a feeling since it's immutable the compiler knows it doesn't have to reconstruct it everyt ime, but i don't know anything beyond that guess
<orbitz>
tsuyoshi: the pain of side effects:)
<tsuyoshi>
and what about arrays and tuples? would arrays be like mutable records and tuples like immutable records?
<orbitz>
i do not know
<tsuyoshi>
hmm.. now that I think about it, immutable constants are put into a special area that isn't checked by the garbage collector
<orbitz>
but under the crcumstances you'd be using == vs =, do you care?
<tsuyoshi>
so anything that's mutable has to be constructed fresh at runtime
<tsuyoshi>
that probably explains everything
Yoric[DT] has quit ["Ex-Chat"]
<tsuyoshi>
orbitz: well with = it doesn't make any difference, with == if you are creating a new value it can screw things up
<orbitz>
screw what up though?
<orbitz>
if you are interested in reference equality then you shouldn't care if it's really equal via =
<RobertFischer>
You probably shouldn't ever be interested in reference equality.
<RobertFischer>
:P
<tsuyoshi>
reference equality is much quicker sometimes
<orbitz>
most of the time i'd say, but that doesn't make it useful
<orbitz>
you could use == as a equick check prior to doing = if you think you are going to be working with mostly referencially equal object i suppose
OChameau has quit ["Leaving"]
<rwmjones>
type s = { f : int -> int; }
<rwmjones>
and then make generates different structures each time
<tsuyoshi>
orbitz: I think = already does that
<nysin>
http://pastebin.com/m7d19cfda - so, when I try to run this on a ~6.6MB XML it takes about 30 seconds (on an old, secondary machine admittedly, but still). When I gprof it ~3/4 of the time at least is in garbage collection routines. I've therefore looked to remove as many unnecessary memory allocations as I can find. What have I missed?
<petchema>
tsuyoshi: not sure, because it would be incorrect for nan (IEEE specifies that nan <> nan)
<tsuyoshi>
nysin: recursive functions generate a lot of garbage.. your best bet is probably just to adjust the garbage collector
<nysin>
tsuyoshi, that's (nearly) all tail recursion
<tsuyoshi>
right
<nysin>
one reason I'm using extlib, because it fixed some of the library routines to do that too
<nysin>
Okay, so how do they generate garbage?
<nysin>
they're (theoretically) goto's
<tsuyoshi>
well.. the arguments to each function call (tail call or not) will generate new values
<tsuyoshi>
hence new garbage to collect
<nysin>
even if it's all using the :: constructor?
<nysin>
i.e. the values already exist, I thought
<tsuyoshi>
hrm.. not sure
<tsuyoshi>
but seriously I would rather tune the garbage collector than rewrite that code
<nysin>
Alright. Well, what adjustments would you suggest to the GC then? I've never played with that on O'Caml.
ygrek has joined #ocaml
<nysin>
(also, to be clear, the parse call, which invokes all the := stuff, takes less than a second. The parts that take a long time are basically purely functional)
Linktim has joined #ocaml
olleolleolle has joined #ocaml
<tsuyoshi>
nysin: well.. have the program run and look at the statistics (Gc.stat)
filp has quit ["Bye"]
olleolleolle has quit [Client Quit]
<tsuyoshi>
I'm not really an expert on this but I guess if you have a lot of minor collections, increase the minor heap, if you have a lot of major collections, increase the major heap increment
<nysin>
Okay, got some stats. Not sure yet how to interpret them
<nysin>
minor_collections: 1269;
<nysin>
major_collections: 22
<petchema>
when you have lots of short lived objects, increasing the size of the minor heap can be worth a shot (it reduces the amount of promoted objects, lowering the work done by major collection)
<nysin>
Is that high or low?
<nysin>
Oh, promoted_words: 27928982 (27 million words)
<nysin>
Again, I have no point of reference here
<tsuyoshi>
yeah I'd go for increasing the minor heap size
Linktim_ has joined #ocaml
<nysin>
okay
<tsuyoshi>
maybe set it to 1024 * 1024
<tsuyoshi>
(will make the minor heap 4 megabytes on a 32-bit system)
<nysin>
haha, that was pretty dramatic
<nysin>
30s -> 4.4s
Yoric[DT] has joined #ocaml
<nysin>
making it 40MB (yeah, probably larger than it should be but) reduces it to 2.8s
<Yoric[DT]>
hi
<nysin>
(and, I'll stop spamming after this, but thanks for that suggestion - the [unsustainable probably] 200MB minor heap brings it to 2s flat)
Linktim has quit [Read error: 110 (Connection timed out)]
jlouis has joined #ocaml
Linktim_ has quit [Remote closed the connection]
Linktim has joined #ocaml
OChameau has joined #ocaml
rwmjones_ has joined #ocaml
bluestorm has joined #ocaml
filp has joined #ocaml
OChameau has quit ["Leaving"]
Snark has joined #ocaml
olleolleolle has joined #ocaml
al-maisan has quit ["Leaving."]
RobertFischer has quit []
qwr_ has joined #ocaml
qwr has quit [Read error: 110 (Connection timed out)]
<gildor_>
someone has a snippet for making sexplib work with ocamlbuild ?
LordMetroid has joined #ocaml
<tsuyoshi>
hahah 196 megs to save 2 seconds
sirius6b has joined #ocaml
<nysin>
And the machine it's running on is an 800MHz Duron. I did say it was old.
smimou has quit ["bli"]
qwr_ is now known as qwr
enri_bass has joined #ocaml
rwmjones_ has quit ["Closed connection"]
coucou747 has quit ["bye ca veut dire tchao en anglais"]
<hcarty>
I have used the first link in several project, but never with sexplib
<hcarty>
I have not used the second
<flux>
is it me of has the traffic on the caml mailing list greatly diminished as the time has passed on..
<tsuyoshi>
it seems more active to me
<flux>
well, truth to be told, I'm just following the weekly news
<tsuyoshi>
but maybe the signal ratio is just going up
<flux>
but perhaps there aren't that many report-worthy items then
<flux>
people concentrating on Core ;)
<tsuyoshi>
less beginner questions and more neat stuff
<hcarty>
flux: The weekly news has been much quieter
<tsuyoshi>
core looks really cool
<sirius6b>
I need to return list of strings being read from a file. AFAIK it is essentially imperative procedure and apart from recursive function I find employing reference stuff as the only way to do that. Is there any other way?
<flux>
there is, but it's annoying without helper functions
<sirius6b>
which helper functions?
enri_bass has left #ocaml []
<flux>
but it would go like this: let read_file f = let rec loop aux data = match try Some (input_line f) with End_of_file -> None with Some v -> aux (v::data) | None -> List.rev v in loop []
olleolleolle has left #ocaml []
<flux>
a mechanism for readingin put without needing to handle exceptions
<flux>
or a mechanism for converting exceptions to values
RobertFischer has joined #ocaml
<Yoric[DT]>
FWIW, I've put that in Batteries Included.
<flux>
what's the url for it, btw? I may have asked this earlier, but I can't find it now..
<flux>
ah, I must've restarted my irc client
<flux>
found it
<nysin>
val input_list : in_channel -> string list
<nysin>
(** Returns the list of lines read from an input channel. *)
<nysin>
from extlib
<flux>
I suppose there's also some with_file so you can easily read contents of a named file?
<flux>
maybe I should start using one of these collections; or move my commonly used functions into an ocamlfindable module of its own
<nysin>
yeah there is
<flux>
hm, I currently have extlib installed
<flux>
so it has the same name?
<bluestorm>
it's in Std iirc
<nysin>
Well it's orthogonal to this. input_list just uses whatever in_channel it's given
ygrek has quit [Remote closed the connection]
<nysin>
So the same with_whatever (forgot its name) works
<flux>
nysin, yes, I was just wondering is there a with_whatever function to use it with
<mbishop>
I think these extension packs are ok, but would be nicer as seperate modules in some type of packaging system
<flux>
Error: Unbound type constructor Std.result Exit Code 2 - Stopped - oh no, I hope this doesn't mean I actually need to read those pesky README files there?!
<flux>
or maybe svn HEAD is just broken
<nysin>
flux, huh. I rather thought such a thing existed. I just looked and I didn't find it so...
<mbishop>
and hear I though README stood for Really Exciting And Dogmatic Manager Emails
<mbishop>
here*
<flux>
it appears the installation proceduce isn't quite finished yet
Snark has quit [Remote closed the connection]
<gildor_>
hcarty: thx for links but in fact i was looking to use the ocamlbuild ocamlfind plugin (first link) as is (without the trick of the second link)
<flux>
nope, it installs as "extlib"
<flux>
with the same version number too
<nysin>
(oh to clarify: when you ask about with_file you specifically have that in mind rather than the open_in{_bin} which doesn't clean up after itself, correct?)
<flux>
I was thinking of a function with val with_file : string -> (input -> 'a) -> 'a, after which the file is no longer open
<nysin>
alright, so I did understand your question
<flux>
yoric's extlib has it: val with_file_in : string -> (input -> 'a) -> 'a
<spanish_mathish>
hello, is there any information of how to profile ocaml programs?
<tsuyoshi>
yeah there's a profiler.. ocamlprofile iirc
<nysin>
and gprof for native-compiled code
<flux>
spanish_mathish, ocamlprof is documented in the manual, for each line it gives the number times is has been visited. with native binaries you can use gprof.
<nysin>
with the -p option
<nysin>
on ocamlopt
ygrek has joined #ocaml
<spanish_mathish>
and coverage too?
<flux>
I haven't really looked, but I suppose gprof would do that doo
<flux>
I must say I'm much more impressed with extlib's level of documentation (and the look of mli-files in general) than with Jane St's OcamlCore
<flux>
yoric[dt], so keep on the good work :)
<Yoric[DT]>
Thanks :)
<flux>
yoric[dt], btw, how is the 'a output -type supposed to be used effectively?
<Yoric[DT]>
What do you mean ?
<flux>
I mean, what's the point?-) Pervasives.output doesn't have a type variable..
<flux>
type Pervasives.out_channel that is
<flux>
yoric[dt], let's say I collected some feedback and wanted to give it back.. which would be the best medium? irc, mail or providing a patch?-)
<Yoric[DT]>
Just one thing: I'm not the author of 'a output.
<Yoric[DT]>
I just submitted about 30 one-liner functions :)
<flux>
right
<Yoric[DT]>
Can I assume it's my name appearing near the top of the file that made you think I was the original author ?
<Yoric[DT]>
I do realize that there's an ambiguity but I haven't found any satisfactory way of writing "hey, I'm the latest contributor" than adding my name after that of the original author.
<hcarty>
gildor_: Understood. I can't offer more help then, sadly.
<spanish_mathish>
has ocaml finalizers?
<spanish_mathish>
when an object is not being referenced, how to self finalize this object?
<Yoric[DT]>
Indeed, it does. Module Gc.
* Yoric[DT]
fails to understand "self-finalize", though.
<hcarty>
Gc.finalise is the specific function, I think
<spanish_mathish>
what is the method of finalizer?
<gildor_>
hcarty: ok, so i will try to find a good solution
<gildor_>
by myself
<spanish_mathish>
by example, if the object Database is not being referenced more then this object Database calls to method finalizer to close all its connections and opened files.
<hcarty>
spanish_mathish: You have to use Gc.finalise to tell the GC "call f (a) when a is collected"
<flux>
spanish_mathish, I believe it is inadvisable to use finalisers as the sole resource control mechanism
<Yoric[DT]>
spanish_mathish: there's nothing specific to objects, btw.
* Yoric[DT]
agrees with flux.
<flux>
you could easily consume all the resources in certain cases before the gc is going to give them back
<nysin>
This is actually one of the few bits of C++ (and D) which I like - with RAII this with_foo is implicit. Macros can do this too of course.
<nysin>
But it's still not quite as automatic
<flux>
it's not quite as automatic, true
<flux>
but that's a good point, actually. could one emulate a (say) reference counted object in ocaml with macros?
<flux>
I suppose it should be quite straight forward
<flux>
but then again, it doesn't go well with tail recursion
<nysin>
I hadn't thought of that.
<Yoric[DT]>
You mean emulating with_foo with macros ?
<flux>
but it would be something to show those c++ people ;)
<flux>
yoric[dt], no, but for example declaring ref-counter variables, decrementing the count when they go out of scope etc
<Yoric[DT]>
iirc, with_foo is just try...finally...
<nysin>
Sure
<flux>
however one would need to be careful when passing them as arguments and receiving
* Yoric[DT]
guesses it's feasible.
<flux>
I wonder how one would define a function that receives a ref-counter argument
<Yoric[DT]>
I would look upon such macros with suspicion, though.
<flux>
this would all need to be quite bullet-proff, too
<nysin>
But it's still nicer to just know that because one has declare ~ObjectType no matter what that'll be run when something goes out of scope
* Yoric[DT]
has suffered enough of ref-counting in C++.
<flux>
I think without a special naming convention for such variables it wouldn't work
* Yoric[DT]
wishes to add that ref-counting often just doesn't work, whether in C++, Python or Objective-C.
<Yoric[DT]>
(never tried in other languages)
<nysin>
Yeah as a general replacement for GC it has well-known problems
<Yoric[DT]>
And I mean not just cycles.
<nysin>
I have in mind more specific situations where there's a managed resource that has to be released quickly
<Yoric[DT]>
...or concurrency
<nysin>
But there are a lot of those situations
<Yoric[DT]>
For this kind of things, I'd use with_foo.
<Yoric[DT]>
But yes, I understand how it could be difficult in some circumstances.
<hcarty>
Is there a way to do something along the lines of "include module Foo with type t = t'" to extend module Foo with a redefined type, without resorting to functors or needing to manually define a module signature?
<spanish_mathish>
nysin, OCaml's GC is one of the best, but apparently is worser if it's enabled the concurrency or its heap is gigant.
eelte has joined #ocaml
<nysin>
spanish_mathish, oh responding to my question from a while ago? That's pretty interesting actually...
<nysin>
if it has such behaviour
<nysin>
hcarty, well functors don't need much syntactic overhead - if it's just one type you need then it can all be done inline in the functor definition in 20-odd chars
mfp_ has joined #ocaml
coucou747 has quit [Read error: 110 (Connection timed out)]
<flux>
yoric[dt], btw, I read through the OcamlCore .mli-files, and there was a good point about assq etc functions: a nice alternative is to just have them take a function in, it's not much different to say index_of 42 list vs. index_of ((=) 42) list; there is a cost in performance, though..
<flux>
(the point was that it may be difficult to remember which functions use physical and which structural equality)
<Yoric[DT]>
iirc, both appear in Batteries
mfp has quit [Read error: 110 (Connection timed out)]
<hcarty>
nysin: I have a module defined already, and I would like to redefine module_t - only a few functions would have to change in this process
<Yoric[DT]>
index_of x is just a shortcut for find (( = ) x)
<Yoric[DT]>
index_ofq x is just a shortcut for find (( == ) x)
<Yoric[DT]>
etc.
<flux>
ah, you mean fst (findi ..)
<Yoric[DT]>
Oh, yeah, something like this.
* Yoric[DT]
doesn't have the code handy at this moment.
* Yoric[DT]
is trying to get some work done on his static analyzer.
<flux>
the character q seems to be a good hint. I wonder why, though, what does it have got to do with physical equality?-)
<spanish_mathish>
ocaml reduces it to Weak Normal Form before of to realize Beta-reduction.
<Yoric[DT]>
flux: no clue :)
<Yoric[DT]>
I just adopted existing conventions.
mfp_ is now known as mfp
<nysin>
hcarty, maybe I misunderstand but I'm not sure how that differs betweena functor and what you're asking about. Either one can/would hypothetically be able to make a module that other functions can use fine without being changed
pango has joined #ocaml
<hcarty>
I think, though I am not sure, that I would have to rewrite my existing module Foo as a functor FooFunctor, and use FooFunctor to create FooOld (with foo_t) and FooNew (with new_foo_t)
<hcarty>
In the functor case, I need to rewrite Foo, which I would prefer to avoid
<nysin>
oh
<nysin>
yeah
<hcarty>
But if I can not avoid it, then I'll just have to rewrite it. Or copy+paste.
filp has quit [Read error: 110 (Connection timed out)]
<spanish_mathish>
hcarty, you can use signatures
<spanish_mathish>
instead of rewriting
<nysin>
(I mean it's a pretty trivial 'rewriting' and there should be no copy/pasting going on)
filp has joined #ocaml
<hcarty>
spanish_mathish: Yes, I was just hoping to avoid that since the signature would have to be maintained in parallel with the implementation
<hcarty>
That signature is not a problem in general, but this code is being altered very frequently so it would slow things down
<spanish_mathish>
the signatures are precious for me, imagine, a Graph signature
<spanish_mathish>
with its algorithms of Graphs
<nysin>
hcarty, Ocaml doesn't use nominal types for this
Snark has joined #ocaml
<nysin>
so if the functor only cares about certain aspects of the full module containing foo_t and new_foo_t then the sig doesn't have to change every time the associated structs do, necessarily
<spanish_mathish>
and i can do by example, return the stronger components of a forest of files.
<hcarty>
nysin: I think I will have to use a functor, or signature, as in this case the current module uses an 'a array array and the new one will use a Bigarray.Array2.t in its place
<nysin>
Well this does seems like a pretty good use for functor.
<hcarty>
Probably. I'm just a little worried about the performance overhead. But this should be easy to defunctorize by hand if it becomes an issue.
AxleLonghorn has joined #ocaml
<spanish_mathish>
The signatures/functors are good for reusing existing complex algorithms instead of re-implementing them.
AxleLonghorn has left #ocaml []
<nysin>
Yeah. Apparently there are sometimes issues with functors not being inlined - or so I've read.
palomer has quit [Read error: 113 (No route to host)]
<spanish_mathish>
if you want more speed then make a 2nd improved version, later 3rd, and so on.
<spanish_mathish>
if you want not more speed then reuse!
evn has joined #ocaml
<RobertFischer>
Is ocamldefun still being supported?
<tsuyoshi>
last I heard it was way out of date
<RobertFischer>
Too bad.
smimou has joined #ocaml
<spanish_mathish>
the another option is to use the ocaml preprocessor
<nysin>
3.06-out-of-date it seems
<spanish_mathish>
my question is
<spanish_mathish>
can be improved the current ocaml implementation for better templating of the signatures/functors?
evn has left #ocaml []
<orbitz>
what is wrong with it currently?
<nysin>
"Yes." :p
<nysin>
(I mean, it's not likely it's the most perfect potential implementation out there.)
<spanish_mathish>
orbitz, it can be wrong if it can be improved
<orbitz>
most anything can be imporoved, it might nto be worth it
<nysin>
Though MS, unlike Sun, favours a bit more precompilation I think, to native-ish code.
<orbitz>
spanish_mathish: the current ocaml bytecode impl does no do JIT AFAIK
<spanish_mathish>
:(
<orbitz>
why a frown?
<spanish_mathish>
bytecode + profiling + optimizing generator of hot zones
<nysin>
... is one way of implementing a language.
<spanish_mathish>
without much complication
<orbitz>
that is very complicated actually
<orbitz>
optimizing is more than a runtime flag
<spanish_mathish>
profiling the bytecodes is easy
RobertFischer has left #ocaml []
<spanish_mathish>
identifying hot zones is easy
<spanish_mathish>
and transforming hot bytecodes to optimized native code is half complicate
<hcarty>
spanish_mathish: Why not just use native code directly?
<jlouis>
JIT is much harder to get right than just compiling directly to native code
<spanish_mathish>
hcarty, first, you can't predict the conditional branchings, you can't predict the most used registers or variables for Reg.Allocator, etc.
<nysin>
Well there are arguments for it though - it can be viewed as continuous profile-guided optimization
<spanish_mathish>
exact!
<spanish_mathish>
and because whole optimizing is expensive, but the hot zones optimizing is cheap
<orbitz>
if it's so easy then better hop to it mr
<pango>
don't cpus do very good conditional branching prediction those days (over 98% accurate ?)
<jlouis>
pango, true, they can near 99.5 at time
<nysin>
The remaining 0.5% just hurts really badly.
<spanish_mathish>
pango, there is a thing that you don't know
<nysin>
Also various heuristics - if a jump is backwards and short it's probably a loop and therefore probably true, etc.
<pango>
spanish_mathish: more like playing devil's advocate
<spanish_mathish>
what is the block of IF-A-THEN-B-ELSE-C to be emited first in pipeline? B or C? it's unpredictable!
<spanish_mathish>
with the profile, you can approximate it better
<nysin>
And if CPUs can achieve the astonishingly high accuracy rates they indeed do then evidently such things are either not that unpredictable or not significant during runtime regardless.
sirius6b has quit ["Ухожу"]
<hcarty>
Given the speed boost that natively compiled OCaml gives already, I think the language is doing ok. More speed would be nice, but the added complication may be more than the INRIA folks want to maintain.
<hcarty>
Particularly given how little time they have to spend on OCaml
<spanish_mathish>
so, the stalls of CPU-pipeline will be lesser while it's predicting the branchj
<nysin>
spanish_mathish, the dispute isn't that sometimes what you're describing can help. It's whether it helps enough and often enough to be worth implementing given its complexity.
<bluestorm>
as an intermediate between bytecode and native code
<spanish_mathish>
bluestorm, thanks by the reference
<orbitz>
just implementing ocaml on an already solid VM seems sufficietn enough? isn' that where .net and JVM's are goign? language bases
<nysin>
Well the F# people say there were some compromises I think
<bluestorm>
orbitz: iirc functional languages have specific needs that are not necessarily well fulfilled in a generic VM
<nysin>
And I know in general that the CLS-compatible types are usually a subset of what a functional language would want
<nysin>
(for that matter I don't think that unsigned ints are CLS-compatible...)
<spanish_mathish>
orbitz: the pitfalls of the implementations of .net and JVM are various: they can't implement TCO because they register the functions for HotSpoting/JIT, they can't do interprocedural optimization, they can't do inlining functions, they implement genericity instead of templating, etc.
<spanish_mathish>
they don't do lambda-calculus's reductions of high order functions
<spanish_mathish>
and they have not gotos in the language very useful for generators of code
<spanish_mathish>
instead, the programmers obligated to generate bytecodes to use gotos
<hcarty>
spanish_mathish: I read that Scala has at least some tail call optimization, though I don't know the details. And it targets the JVM
<spanish_mathish>
XXX language -> Java without gotos => it makes to the programmer of the code generator the life impossible.
<spanish_mathish>
XXX language -> Java bytecodes => it's the worst remedium.
<nysin>
Hm? Apparently Java bytecode does have a GOTO instruction
Snark has quit ["Ex-Chat"]
<nysin>
So I'm not sure how that's the worst (remedium? hybrid? compromise?)
<spanish_mathish>
s/remedium/remedy
<spanish_mathish>
medicine
<nysin>
oh
<nysin>
Still, what's so bad particularly about generating JVM bytecode?
<spanish_mathish>
nysin, is more easy to generate high level code (with the own compiler of Java) than low level code
<spanish_mathish>
and it's more debuggable
<nysin>
Fair enough. Yeah, it'd be ideal I guess.
<spanish_mathish>
i never do complicate steps
<spanish_mathish>
s/complicate/complicated
<nysin>
That would seem to substantially limit the programs you can write.
<spanish_mathish>
yes, i'm very limited because the baby of A.I. doesn't born
<spanish_mathish>
s/doesn't/has not
<spanish_mathish>
i'm not sure if OCaml is my adequated language for A.I.
<hcarty>
How would I represent a type t in a functor, when one instance will use type 'a t = 'a array array and another type ('a, 'b) t = ('a, 'b, c_layout) Bigarray.Array2.t ?
<nysin>
Waiting for a sentient program-writing AI seems risky.
<nysin>
(I can't tell if you're being sarcastic here.)
<orbitz>
maybe instead of hadding hotspotting to ocaml VM we should builda generic VM for functional languages
<orbitz>
althouhg I think tryign to work those changes into JVM/.Net would be more successfull
<nysin>
hcarty, well functors can be composed...
<spanish_mathish>
orbitz, hybrid functional-imperative languages (because common data structures as arrays, vectors, hastables, sets. ... and ref )
<nysin>
(they're functions from modules to modules so...)
<hcarty>
nysin: I am getting type mismatches, which makes sense I suppose (type t vs type ('a, 'b) t or type 'a t)
<orbitz>
spanish_mathish: what?
<spanish_mathish>
you should build generic VM for hybrid functional-imperative languages
<hcarty>
I do not know the syntax to express this
<orbitz>
spanish_mathish: is it too mcuh to add this to .net or jvm?
<hcarty>
spanish_mathish: While they may not be ideal, I think such alterations are being made to both the JVM and .Net CLR
<nysin>
.Net in particular is being made ever more functional-language friendly
<nysin>
since they're moving C# (see version 3.5 for example) towards being somewhat of a (weak) hybrid
<spanish_mathish>
orbit, or i can a better idea, quantum algebraic functional language, it's using matrices of quantum
<spanish_mathish>
if the new millenium has born
<spanish_mathish>
s/can/can have
<jonafan>
dudes, i am reading the source to a ml compiler written in ocaml, it is so nifty
<nysin>
hcarty, well if there's a module Foo which uses one of Bar and Baz and Bar and Baz each have different numbers of paramters then first make functors which create non-abstract Bar's (not sure of terminology here) and Baz's and then feed those fully constructed modules to Foo, is one way
<spanish_mathish>
more complex is quantum of high order, it's quantum of quantum values (in nested form).
<hcarty>
Wow. That makes for a lot of layers.
<nysin>
Yeah. There are probably better ways of doing it
<nysin>
I'm just not familiar with them offhand
* orbitz
thinks spanish_mathish is degrating into trolldome
<mbishop>
trolldome? Two trolls enter, one troll leaves!
<mbishop>
TROLLDOME!
<spanish_mathish>
the 2nd is inside
<orbitz>
mbishop: i'll only go if Tina Turner does the opening performance
<hcarty>
Functors seem like wonderful tools, but they also seem to become very complicated to implement in these kinds of situations
<spanish_mathish>
alive or death, who know?
<hcarty>
It is not our place to ask why Trolldome works the way it does.
palomer has joined #ocaml
<orbitz>
the only functors i've used are Set and Map, and I wasn't happy with them due to lack of polymorphism ont eh object
<hcarty>
orbitz: I've used and been happy with Map, since the type inference kept everything clean. But writing functors seems to be a whole different monster.
<hcarty>
I wonder if this is any easier to implement with OCaml classes
ygrek has quit [Remote closed the connection]
<hcarty>
Probably not, I think the difference in the number of parameters would still cause problems
<jonafan>
lack of polymorphism?
<jonafan>
you mean on the value?
<spanish_mathish>
jonafan, no problem type 'b = 'a | 'a list
<hcarty>
'a array array vs ('a, 'b, 'c) Bigarray.Array2.t
<hcarty>
jonafan: Sorry, you were replying to orbitz
<jonafan>
yeah
<orbitz>
hcarty: how do you write a function that operates on a mapy of 'a?
<hcarty>
orbitz: I don't understand your question
<spanish_mathish>
do you mean lack of polymorphism 'a, 'b, 'c, ... to Functors?
<orbitz>
hcarty: since Map is a functor i create a new module for each key type. but the problem i always run into (and perhaps i'm doing thign wrong) is what if i want a type whcih will work on a map of any key type
<spanish_mathish>
hahaha
<orbitz>
hcarty: for instance a generic function taht produces a list of keys or list of values
<spanish_mathish>
as in C++'s templates <A, B, C < D, E > >
<spanish_mathish>
before of to instance the templated class.
<orbitz>
i don't think my question relates to C++ templates..
<spanish_mathish>
i think the functors lacks the parameters of templates
<nysin>
orbitz, you're asking for all Ocaml types to be strictly orderable. That seems tricky and of dubious use.
<spanish_mathish>
s/lacks/lack
<palomer>
C++ templates are cool!
<orbitz>
nysin: i'm not sure i am?
<nysin>
Well, I'm more or less assumpting map operates based on some sort of sorted tree
<orbitz>
nysin: a functino that produces all the keys is possible, assuming i take the fold function as part of my input
<nysin>
I suppose that might not be the case.
<nysin>
*assuming
<orbitz>
nysin: hrm i'm not sure i follow. what does the sorted/unsortedness have to do with my question?
<spanish_mathish>
in the past, polymorphism, in the present polymorphism + modules system, in the future, polymorphism + templated modules system
<nysin>
That if (and it seems likely though it should certainly be verified) Ocaml's Map module actually stores data in an ordered tree and you're asking for it to hold any type at runtime then there must be a total and consistent ordering over all potential types such that the tree I'm assuming it can use will actually work. The reason sorted/unsortedness matter is that the point of using say a binary search tree (or various more
<nysin>
complex variations) is that they can achieve O(log n) performance by repeatedly bisecting (or more, for B/B+ trees etc) the possible nodes.
<orbitz>
i don't wnat it to hold any type at run time
<nysin>
oh
<orbitz>
i'm saying that because my map of strings is a module i cannot be polymorphic on anything that is a map
<orbitz>
without makign it part of the functor
<nysin>
oh. right.
<bluestorm>
you can make it part of a functor
<orbitz>
I think someoen on caml-list wrote his own version to do this, hwoever his solution involves taking a compare functino with every function whcih seems kind of annoying
<spanish_mathish>
you need to specify parameter X is Map of Some Y, what hard is it!
<bluestorm>
(and there are non-functorial impl. of map available)
<orbitz>
bluestorm: is it functional?
<bluestorm>
orbitz: Extlib has an implementation with the comparison function at creation time only
<orbitz>
anyways, the poitn of bringign that up was: it's the only experience I have had with functors, so i currently have not found them of much value
<bluestorm>
actually a functor on map is quite valuable, except that you have to use functors yourself to benefit from that
RobertFischer has joined #ocaml
* RobertFischer
is slowly coming to the realization that Ocaml is easier read from the bottom up.
<bluestorm>
(that's the same problem with monads, but a bit lighter because functor-related modifications aren't local to any function)
<bluestorm>
RobertFischer: what do you mean by "bottom up" ? do you have examples ?
<spanish_mathish>
imagine it in Lisp, you've not problems that you had in OCaml
<RobertFischer>
Like, start at the bottom of a file, and the last function first, then work your way up.
<spanish_mathish>
hehehe, is OCaml flexible to be used for A.I.?
<bluestorm>
hmm
<RobertFischer>
I get lost in let...in/let...in/let....in noise at the top of a method: it's easier to start at the body and then read the stuff up top as necessary.
<bluestorm>
RobertFischer: i think this is related to the fact that we need function to have been already declared
<bluestorm>
a "where" keyword would help with that
<RobertFischer>
bluestorm: Yup.
<RobertFischer>
It's not a bad thing.
<bluestorm>
last summer i was thinking of a more general solution to that
<RobertFischer>
It's just different.
<nysin>
spanish_mathish, A.I. is just that which isn't adequately understood. As soon as something it, it magically ceases to be A.I. Therefore, A.I. will never be achieved and certainly O'Caml will never be sufficient. :p
<bluestorm>
(something like "generalized reverse declarations" :p)
<hcarty>
let result = x after ( ... )
<spanish_mathish>
(setq x ....)
<spanish_mathish>
let x = ref 0 in ... In lisp, it's (setf x 0)
<hcarty>
bluestorm and RobertFischer: are you thinking of anything more than just moving the last line (or lines) from the end to the beginning of a function?
<bluestorm>
hcarty: that's "where", right ?
<RobertFischer>
hcarty: I'm not thinking of anything.
<hcarty>
bluestorm: Yes
<bluestorm>
i'm afraid i forgotten my meditation a little while ago, but
<bluestorm>
i have under the hood a syntax for haskell-like function declarations
<hcarty>
RobertFischer: It's getting later in the afternoon, and despite my best effort my effective thinking is trailing off
<bluestorm>
(not really finished though)
<RobertFischer>
hcarty: NP.
<bluestorm>
where you can name the function several times with different patterns, and a type annotation
<spanish_mathish>
the same syntax in Haskell can be made in Lisp similarly
<spanish_mathish>
using special symbols
<spanish_mathish>
Lisp doesn't understand polymorphism but it can do more things than the polymorphism because the data can be code too
<nysin>
Have you looked at CLOS ...?
<spanish_mathish>
yes, CLOS is for OO
<nysin>
And that's how it does polymorphism more or less.
<spanish_mathish>
it does polymorphism using single inheritancy
<nysin>
Um.
<bluestorm>
however it's a very heavy extension (but it's probably not implemented right, i was very new to camlp4 at that time) and wouldn't cooperate well with others in the current state (redefine "implem" and clear "str_item")
jdrake has joined #ocaml
evn_ has quit []
<bluestorm>
hm
<bluestorm>
actually the tiny point of relevance of that file (apart from showing my elite camlp4 skillz) is that the post-processed definition are put in the order of occurence of the first defining line
<bluestorm>
so you could only put the "prototype" ahead, and then declare them later
<hcarty>
bluestorm: Very nice
<spanish_mathish>
what about annotations in Ocaml?
<Yoric[DT]>
bluestorm: I concur, nice.
<spanish_mathish>
or AOP, or instrumentation in OCaml, ...
<bluestorm>
spanish_mathish: what kind of annotations are you talking about ?
<spanish_mathish>
as from Java5
<spanish_mathish>
@deprecated by example
<spanish_mathish>
@overrides ...
<RobertFischer>
spanish_mathish: You don't want instrumentation in OCaml. And I -- coming from Java -- haven't missed annotations.
* Yoric[DT]
misses @deprecated, vaguely.
<RobertFischer>
spanish_mathish: You should probably code a bit with Ocaml before you start lamenting the things it's missing.
<bluestorm>
python decorator would not be difficult to provide with a syntax extension
<spanish_mathish>
or @facade Joe's
<RobertFischer>
I don't miss @deprecated in Java: it means "Oh, watch out -- I'm going to get rid of it! Really, I am!", but they never actually do get rid of it.
<spanish_mathish>
it's code OCaml using the facade of Joe
<Yoric[DT]>
RobertFischer: well, it's more along the lines of "please don't use this, pretty please".
<Yoric[DT]>
Or, more generally, of adding warnings inside code.
<RobertFischer>
If they do get rid of it, it'd be a compile-time error, so I care less.
<nysin>
RobertFischer, I'm seeing that now - I'm told that someone somewhere might use it so... :p
<RobertFischer>
Yoric[DT]: But the warnings are bogus. So this method may go away in two years or so....maybe. Shut up about it, already.
<RobertFischer>
Yoric[DT]: (The "shut up" was for the compiler warnings, not you.)
<Yoric[DT]>
:)
<jdrake>
Is it conceivable to have an MVC application, where the model is in ocaml and the view/controller is in something like smalltalk?
* nysin
can conceive of anything.
<spanish_mathish>
@model MVC
* Yoric[DT]
agrees with nysin.
<RobertFischer>
jdrake: Sure. But why would you want to?
<Yoric[DT]>
Anything is possible, provided you're willing to go far enough to do it.
<RobertFischer>
jdrake: If you're thinking of Ruby when saying "something like smalltalk", check out rocaml.
* Yoric[DT]
has already attempted socket communications inside one application, to get nuts and bolts from different languages together.
<jdrake>
I am starting a paper design for a CAD program, and I think ocaml would be suited for the 'engine'.
<jonafan>
actually i've seen something with the gui in python and the model in ocaml
<jdrake>
RobertFischer: I feel ruby is the work of satan.
<nysin>
I mean, yeah, static typing would find certain bugs, and it's not the best thing ever, so I guess in some sense it's causing those specific bugs, but a fundamental problem?
<RobertFischer>
Anyone know where prerr comes from?
<RobertFischer>
And prerr_endline?
<nysin>
as for the strawman, things such as "The next person who tries to tell me that dynamic typing is the best thing since sliced bread is going to get an earful.". Which I'd take to be harmless rhetoric except that you use that to ping-pong back to "It is a flat-out wrong position, and I’m done hearing otherwise from anyone."
<Yoric[DT]>
PR is often for Portable Runtime, as in NSPR.
<Yoric[DT]>
Oh.
<RobertFischer>
hcarty: Oh, sweet.
<spanish_mathish>
i think that scheme is the supreme language because of SICP
<Yoric[DT]>
Well, maybe not :)
<nysin>
oh, you have a slightly more reasoned version too, all is well.
<jdrake>
What other languages have been implemented in ocaml, in a generally useable fashion?
<hcarty>
Yoric[DT]: I was just looking for an excuse to use the new GODI search :-)
<spanish_mathish>
but it lacks OO
<Yoric[DT]>
:)
<RobertFischer>
nysin: Yeah, I was a bit cranky when I wrote that. I had just spent all this time being told by Rubyists how awesome dynamic typing and Ruby is, and here they can't even keep their standard library together.
<jonafan>
lacking oo isn't a deal breaker
<nysin>
Yeah, I agree with the comment where you elaborate on it
<nysin>
I can understand that response at least though
<RobertFischer>
nysin: There's certainly some overstatement in the main post (I moderate a bit in comments), although I stick by the statement that dynamic typing is bogus for any application that's bigger than one file.
<spanish_mathish>
a little of Scheme, a little of Smalltalk, the new language is more flexible
<jonafan>
jdrake, did you see those links
<RobertFischer>
nysin: And the fact that Ruby can't keep their standard library *compiling* kinda proves my point. :P
<nysin>
I'm going to remain neutral on that for now. I write a lot of Python (no Ruby actually) and whilst it's all worked fine, no individual project has ever been more than a single file.
<nysin>
Ruby may well have problems of its own there. :p
<jdrake>
jonafan: yes
<jonafan>
ok good
<nysin>
I tend to think that a lot of the attacks on static type systems are due to people not seeing any static type system made after, say, 1975
<jdrake>
jonafan: I am looking for something very stable, I am not sure something that is '0.1' is a reasonable thing to use
<jonafan>
yeah, i probably wouldn't use it
<hcarty>
This functor thing is driving me nuts. It may be time to just copy and paste and accept the scorn of the FP world.
<jonafan>
it seems a little bit like a rube goldberg invention
<spanish_mathish>
remember the words of ... Donald Knuth
<jdrake>
Has anyone made a real gui (for a serious application) in ocaml? If so, what is it like?
<spanish_mathish>
"premature optimization is the root of all evil"
<jdrake>
spanish_mathish: Knuth is like my prophet!
<jonafan>
mldonkey and unison are both popular ml projects
<RobertFischer>
nysin: Check out that Ruby script I link to -- the one on closures in Ruby. It's interesting.
<nysin>
Or in a systematic way. So there are function (refs) and proc-function refs, but I never grasped why there had to be such, unless just for the cosmetic 'hey we don't need parens to call' thing
<nysin>
which seems dumb
<nysin>
Link from? I don't see it in the second post
<nysin>
and the first links to various things but I don't see it there either
<nysin>
oh
<nysin>
nevermind
<spanish_mathish>
call with continuations and closures in Scheme is interesting
ikaros has quit ["segfault"]
<nysin>
haha. That's pretty bad.
<spanish_mathish>
but easily reusable
<nysin>
spanish_mathish, hm? commenting on the linked script to which RobertFischer refers. Your comment, by contrast, was so generic ("X is interesting." Great.) it wasn't worth responding to :p
<spanish_mathish>
hahaha, both use closures
<spanish_mathish>
but the syntax of one is more pretty than the another
nysin has quit ["Leaving"]
psnively has joined #ocaml
psnively has quit [Client Quit]
psnively has joined #ocaml
RobertFischer has left #ocaml []
<gildor_>
ertai: ping
<hcarty>
Can anyone tell me why this is:
<hcarty>
# let f x = let x' = Array2.create (Array2.kind x) c_layout 10 10 in x'.{0,0} <- x.{0,0};;
<hcarty>
val f : ('_a, '_b, 'c) ExtBigarray.Array2.t -> unit = <fun>
<hcarty>
I don't understand why the '_a and '_b are not 'a and 'b
<hcarty>
Looking through the mailing list shows some similar problems due to partial application
<hcarty>
But there is no partial application here.
jdroid- has joined #ocaml
<hcarty>
let f x = let x' = Array2.create (Array2.kind x) c_layout 10 10 in Array2.fill x' x.{0,0}; x';; is polymorphic as I would expect
jdroid- has left #ocaml []
LordMetroid has quit ["Leaving"]
filp has quit ["Bye"]
<bluestorm>
Yoric[DT]: LList miss "is_nil" and "cons"
<bluestorm>
hmm
<jdrake>
Does ocaml have continuations? (Note that I say this without properly understanding them)
<bluestorm>
(miss ? lack)
<Yoric[DT]>
bluestorm: lacks.
<Yoric[DT]>
jdrake: you can build continuations but they are not part of the language.
<Yoric[DT]>
bluestorm: duly noted.
* Yoric[DT]
will fix that in Batteries Included.
<bluestorm>
:D
<Yoric[DT]>
mmmhhh....
<Yoric[DT]>
Doesn't seem to exist in List either.
<Yoric[DT]>
That is, "is_nil" (or "is_empty").
<Yoric[DT]>
Fixed in Batteries (not committed yet).
<bluestorm>
it's not a problem in List
<bluestorm>
the problem with lazy lists is that a naive equality test may raise an error
<bluestorm>
so a is_nil test require a careful force (and the "length" is not a possibility as it force through the list)
<Yoric[DT]>
Annoying, but fair enough.
<bluestorm>
btw., i'm not sure it's really necessary but a function that would answer the question "has the list at least n elements ?" could be helpful (and (that_function 0 list) could stand for a good is_nil test)
<bluestorm>
hm (that_function 1 list), of course
<bluestorm>
(would_nth_fail : beautiful name, isn't it ?)