<thedark>
the bug was in the big -> big int conversion of caml
<thedark>
or more precisely in my way to test my program.....
<seth_>
thedark: that's interesting
<Vincenz>
thedark: how so?
<seth_>
brb
<thedark>
well i was trying to cast an int to a big_int, but the int was seen as a negative number by ocaml
<thedark>
i havent figured out how to launch a function with a big int as a parameter
<Vincenz>
ah
<thedark>
since fun (big_int_of_int foo) will not work with a big int..
<Vincenz>
anyways
<Vincenz>
I'm crashing
<thedark>
(and eventually cast to a negative number )
<Vincenz>
very tired
<thedark>
same
<Vincenz>
3am
<Vincenz>
have slept 5-6 hours last few nights
<Vincenz>
tomorrow I have to work :(
<Vincenz>
time to hit the sack
Vincenz has quit []
docelic is now known as docelic|sleepo
thedark has quit [Read error: 60 (Operation timed out)]
TimFreeman has joined #ocaml
<TimFreeman>
I have code that creates an exception and marshalls it. Another program unmarshalls it and tries to match against it. Matching fails even though the exceptions have the same name and are generated by the same compilation of ...
<TimFreeman>
a .ml file. Any idea how to get the matching to succeed?
<seth_>
TimFreeman: is the exception defined in a separately compiled file and included with both programs?
<TimFreeman>
Oops, I was afk. Yes, the exception is defined in a file C_compile_exn that is included in both programs. The failing code reads:
<TimFreeman>
match exn with
<TimFreeman>
C_compile_exn.Ncconstr n -> n
<TimFreeman>
| _ -> failwith
<TimFreeman>
(Printf.sprintf "Bad exception %s passed to ncconstr_eventdesc"
<TimFreeman>
(Printexc.to_string exn))
<TimFreeman>
and it prints
<TimFreeman>
Fatal error: exception Failure("Bad exception C_compile_exn.Ncconstr(_) passed to ncconstr_eventdesc")
<TimFreeman>
so the printed representation is exactly the same as what isn't matching in the source file.
<TimFreeman>
There is only one C_compile_util. No functors involved.
<seth_>
so you aren't trying to raise it in the second program, just print information about it?
<TimFreeman>
Extract information from it. "exn" is the only extensible data type. Didn't feel like battling with polymorhpic variants.
<seth_>
No, you shouldn't need to.
<TimFreeman>
seth_: So my answer to you is "yes", more or less. shouldn't need to what?
<seth_>
shouldn't need polymorphic variants
<TimFreeman>
Well, the ... afk again...
<seth_>
So it didn't exactly fail pattern matching, it bombs out about the marshalled value.
<TimFreeman>
I'm back. If the pattern matched, it wouldn't have got to the failwith.
<seth_>
yes, but the message doesn't say that it couldn't match, rather that it is a bad value. So it fails because the object is messed up, not because the pattern is wrong.
<mrvn>
Your marshaling an exception?
<TimFreeman>
The message is generated by my Printf.sprintf code. It fails because it reaches that point in the code. Yes, I'm marshalling an exception.
<seth_>
I suspect that you need to extract the info you want and send it as part of another, marshallable object.
<mrvn>
Are you marshaling functions?
<TimFreeman>
nrvn: No, I'm not marshalling functions.
<mrvn>
exceptions are somewhat special, could be you need to.
<seth_>
Isn't it trying to unravel a stack that belongs to the other process instead of its own?
<TimFreeman>
If there's no obvious way to get this to work, I'll make a simple variant type and marshall that. But then I have to extend it in one central place whenever more alternatives pop up.
<TimFreeman>
seth_: No stacks involved. What are you talking about?
<mrvn>
seth_: One should be able to unmarshal it and raise it again.
<seth_>
mrvn: But he isn't raising it again, he is just dumping info from it.
<seth_>
TimFreeman: I meant the call stack, not a stack in your program.
<TimFreeman>
I agree with mrvn, but I'm not raising it. What call stack are you talking about?
<seth_>
TimFreeman: the executing program has a call stack.
<TimFreeman>
If you don't raise the exn, then there's no connection between the exn and any stacks anywhere. If the exn doesn't store a stacktrace, then there's never a connection between the exn and a stack.
<mrvn>
Hmm, the closures flag shouldn't be the problem. if it where marshaling an exception should barf.
<TimFreeman>
mrvn: Agreed. I'm not making any closures, so I agree twice.
<TimFreeman>
Oh well, looks like the accumulated wisdom of IRC isn't making an instant solution here. I gotta eat dinner. I'll report this to caml-bugs and use a variant instead of an exception. afk for an hour.
<mrvn>
Do you use the same code to marshal und unmarshal the data? recompiling can invalidate marshaled data.
<seth_>
mrvn: I'm still a bit cloudy on when to use the double semicolon (;;) in a compiled program.
Kinners has joined #ocaml
<mrvn>
never
<mrvn>
;; is a special thing for the runtime to say "evaluate and gimme a prompt"
<mrvn>
(afaik)
skylan has quit ["EPIC Panic: EPIC4-1.0.1:Referential integrity failure: Channel [#emacs] on server [0] is connected to window [18] on server [0"]
skylan has joined #ocaml
TimFreeman has quit [Read error: 110 (Connection timed out)]
TimFreeman has joined #ocaml
mattam has joined #ocaml
TimFreeman has left #ocaml []
Kinners has left #ocaml []
lament has joined #ocaml
TachYon has joined #ocaml
TachYon has quit ["Client Exiting"]
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
polin8_ has joined #ocaml
mrvn_ has joined #ocaml
mrvn has quit [Read error: 54 (Connection reset by peer)]
polin8 has quit [Dead socket]
lament has quit ["Support Darwin Awards! Join the military!"]
Vincenz has joined #ocaml
docelic|sleepo has quit [Connection reset by peer]
_BT has quit [brunner.freenode.net irc.freenode.net]
seth_ has quit [brunner.freenode.net irc.freenode.net]
mellum has quit [brunner.freenode.net irc.freenode.net]
Jimzy has quit [brunner.freenode.net irc.freenode.net]
avn has quit [brunner.freenode.net irc.freenode.net]
<Vincenz>
hi
<pattern_>
hey
Vincenz is now known as _
<_>
I'm all of you
_ is now known as Vincenz
_BT has joined #ocaml
seth_ has joined #ocaml
mellum has joined #ocaml
Jimzy has joined #ocaml
avn has joined #ocaml
lowks has quit [Read error: 104 (Connection reset by peer)]
lowks has joined #ocaml
Jimzy has quit [Read error: 60 (Operation timed out)]
<systems>
and i remember i saw a webpage which compare a syntax of like a dozen lang
<systems>
was called syntaz across languages or something like that
<pattern_>
i've seen sml code and it seems very similar to ocaml
<Smerdyakov>
It is.
<Smerdyakov>
There is no significant difference if you don't use OO in OCaml.
<systems>
ocaml vs sml, ocaml won by a ko
<systems>
>:)
<Smerdyakov>
Is that supposed to mean something, systems?
<systems>
mmm...it means I think between the two, choose ocaml
<Smerdyakov>
Why?
<systems>
for me, and seriously, one the reputation, two more docs and books , three it was easier to find a compiler and install it and such
<Smerdyakov>
LOL
<Smerdyakov>
If you think it's hard to find and install an SML compiler, you either live 10 years ago or have poor basic computer use skills.
<Smerdyakov>
I don't know what reputation you mean.
<systems>
or didnt really try
<systems>
i didnt really try or looked for one
<Smerdyakov>
The "more docs and books" is certainly a positive point.
<systems>
but, ocaml was there, the book was free, and many websites said it was fast
<Smerdyakov>
MLton produces optimizied output on par with ocaml.
<Smerdyakov>
(MLton is an SML compiler.)
<Smerdyakov>
I think you may be right that OCaml is a better choice at the moment, but it's for a very small number of reasons, not including most of the things you've named!
<systems>
:)
<systems>
at the moment!
<Smerdyakov>
I think a standardized ML language will be the best choice 2 years after it is created, if ever.
<Smerdyakov>
A standard that is actually followed, I mean.
<Smerdyakov>
Since I think ocaml was created after _Standard_ ML :P
<systems>
how would that be better then ocaml
<pattern_>
actually i think it was created before
<Smerdyakov>
Because there would be more compilers for it.
<Smerdyakov>
Presumably the dozen or so free SML compilers out there today would change to read the new standard, along with ocaml.
<Smerdyakov>
By the way, your statement about difficulty of finding an SML compiler is quite funny given that there are at least 10 free ones, and only one current ocaml compiler...
<systems>
yea excatly
<systems>
i was lookin at haskell, and was thinking, ocaml or haskell ...mmmm
<pattern_>
"Why is the syntax of Caml different from SML's one ?" "The main reason is historical: Caml was invented before SML." "The Caml language is issued from the original ML language, invented by Robin Milner in 1978, and developped jointly at INRIA from 1981. The first Caml compiler was written in 1984, and distributed from 1985. Standard ML was not yet invented, and Caml's syntax was similar to the syntax of ML V6.2, whose compiler was used t
<pattern_>
pile the first Caml compiler. When the syntax of Standard ML has been defined, Caml kept its own syntax, for several reasons..."
<systems>
i picked ocaml cause there was only one compiler and because i heard it was faster
<systems>
sml is kinda weird too
<pattern_>
from what i've heard of haskell, i think ocaml is a much better choice
malc has quit [Read error: 110 (Connection timed out)]
<systems>
well the book am reading now, developing apps with ocaml, compare ocaml to haskell from time to time
<Smerdyakov>
pattern_, well, the ML node at www.everything2.com disagrees, but what would I know....
<pattern_>
ocaml is, allegedly, much faster than haskell... ocaml doesn't restrict you to a functional style, and even has oo extensions
<Smerdyakov>
OO extensions don't matter at all to me.
<Smerdyakov>
I haven't written an OO program in years =)
<pattern_>
smerdyakov, well that quote was from the OCaml FAQ... a bit more official than everything2.com, imo
<pattern_>
oo matters to me, simply because i don't know it yet, and i want to learn it
<pattern_>
ocaml makes that convenient, because i don't have to learn a new language to learn oo
<Smerdyakov>
Don't hold your breath, pattern_.
<Smerdyakov>
Even the OCaml creates recommend rarely using OO.
<pattern_>
heh
<systems>
mmm, pattern_ if you just want to learn OO, you should look at other langs like ruby or python
<pattern_>
smerdyakov, i'm not necessarily going to _use_ oo with ocaml... i just want to learn the paradigm
<pattern_>
systems, but then i'd have to learn those other languages :P
<systems>
yea which is great
<pattern_>
if you have the time
<systems>
i want to learn programming , programming in general , so after i looked around i found that
<systems>
you should learn at least 4 different langs, and as much as you can about the OS
<pattern_>
i know probably ten or 12
<systems>
ten or 12 what
<pattern_>
or, rather, i've _learned_ ten or 12 languages
<pattern_>
can't say i know them all anymore
<systems>
none of them is python ....eeeeek
<pattern_>
nope
<pattern_>
perl was good enough for me, to make me not want to bother learning python, which is really similar
<systems>
for me it was the other way
<pattern_>
yeah
<pattern_>
well, i was a sysadmin, and perl was getting popular (around when perl 4 came out)... and python was still pretty obscure
<pattern_>
so i learned perl
<pattern_>
and loved it, btw
<pattern_>
if i were to learn another scripting language, i think it would be ruby
<pattern_>
but at this point i really don't have any reason to
<systems>
i can't disagree
<pattern_>
i might learn scheme or haskell, though
<Smerdyakov>
I've learned way more than 12 languages.... but, as we all know, there are really only around 5 paradigm representatives you have to learn before almost everything else follows instantly.
<pattern_>
simply because most functional programming docs and papers are geared towards scheme and haskell
<systems>
s Smer, which langs do you think one should learn to cover those 5 paradigms
<pattern_>
"When an identifier is defined by an expression which cannot be generalized, the identifier can have a type with unknowns (that is type variables which cannot be generalized) which will be determined (that is assigned a type value) by the usage of the identifier in the rest of the program. These unknown types are special type variables, prefixed by an underscore (e.g. '_a). Beware, these variables stand for unknown types to be determined by
<pattern_>
ype checking process: that's why these variables may disappear, precisely because their type value has been discovered."
<Vincenz>
I know
<Vincenz>
but still...
<Vincenz>
it does the type checking process, changes the type but DOESNT ADD THE FUNCTION THAT CAUSED THE CHANGE IN TYPE
<karryall>
what's your problem exactly ?
<Vincenz>
let x = ref[];;
<Vincenz>
x := (function y -> y)::!x;;
<Vincenz>
x := (function f -> f f)::!x;;
<Vincenz>
the last statement changes the type but doesn't add the function
<karryall>
oh
<Vincenz>
odd, don't you think?
<pattern_>
not in light of the part of the faq i just quoted
<karryall>
that's because fun f -> f f is not typable
<karryall>
that's unrelated to the ref
<Vincenz>
sure f -> f f is typeable
<Vincenz>
very easy
<Vincenz>
('a -> 'a) -> ('a -> 'a) (I think)
<Vincenz>
oh yeah, damn it
<Vincenz>
I thought it was typeable
Vincenz has left #ocaml []
Vincenz has joined #ocaml
<Vincenz>
oops
<Vincenz>
you're right it doesn't work
<Vincenz>
but why does it change the type then?
<Vincenz>
of x?
<Vincenz>
(also in scheme it works....
<pattern_>
the unknowns "will be determined (that is assigned a type value) by the usage of the identifier in the rest of the program..."
<Vincenz>
((\x.x x) (\x.x x)) causes an infinite loop)
<karryall>
it works with recursive types
<Vincenz>
pattern_: yes but it restricts my type again!!!
<karryall>
use ocaml -rectypes
<Vincenz>
ah thank you :)
<karryall>
# fun f -> f f ;;
<karryall>
- : ('a -> 'b as 'a) -> 'b = <fun>
<Vincenz>
alright :)
<Vincenz>
still don't get why it restricts the type of x though...
<karryall>
because the typing begins ... it sees that f is a function, so it restricts the type of x a bit
<Vincenz>
but then it rejects f..
<karryall>
and then the typer sees a problem and stops but x is left with the restricted type
<Vincenz>
that sux
<karryall>
that's just a consequence of using toplevel and '_a type variables
<karryall>
not really a problem with compiled files
<Vincenz>
alright
<Vincenz>
karryall: care to look at some code I wrote and perhaps give some constructive criticism?
<karryall>
sorry, I don't have time to look at it in detail
<karryall>
the code looks nice (functional style)
systems has joined #ocaml
mellum has quit [Read error: 60 (Operation timed out)]
<Vincenz>
thank you :)
<Vincenz>
I'm new to functional programming so
<thedark>
is somebody familiar with the rabin miller test?
<karryall>
thedark: what's that ?
mellum has joined #ocaml
systems has quit ["Client Exiting"]
<Vincenz>
thedark: primality testing?
karryall has quit ["bye"]
<thedark>
Vincenz: yes
<Vincenz>
I just refreshed my memoery
<Vincenz>
what about it?
<thedark>
well i'm supposed to do something for every j with 0<j<l .. my problem is that l can sometimes be equal to 0 .. so 'im a little confused with this test ...
<mrvn_>
Why?
<thedark>
well it seems i've my answer.. it was obvious...
<thedark>
the test is designed for odd numbers only....
<mrvn_>
thedark: 0<j<l means (0<j) && (j<l)
<mrvn_>
no harms done if both are false.
<thedark>
yes ... l was equal to 0 for even numbers.. but the test is not designed for thoses...
<mrvn_>
still works.
<mrvn_>
have those all the time.
<thedark>
i have a function that takes a big_int parameter.. how can i launch it ... fun (big_int_of_int foo) is not what i want...
<thedark>
let k = Random.int (2^30) in <- whats wrong with this, ocaml tells me about 2 :This expression has type int but is here used with type string
<thedark>
hmm another way to ask my question : how do u write a^b in ocaml?
<mellum>
a**b
<thedark>
ok:)thx
<Smerdyakov>
Maybe it would help if you said what you want ^ to do.
<Smerdyakov>
I know of 4 completely different meanings for it in various programming languages.
<mellum>
Pointer dereferencing, power, xor and string concatenation?
<Smerdyakov>
Yay! You got them!
<mellum>
Do I get w washing machine?
<Smerdyakov>
You get x washing machine.
<mellum>
s,w,a,
<thedark>
let k = Random.int (2**30) in tells me about 2 :
<thedark>
This expression has type int but is here used with type float
<thedark>
any ideas on how to solve this ?
<mellum>
thedark: use lsl
<thedark>
lsl?
<mellum>
logical shift left
<mellum>
pow is for floating point
<thedark>
oh ok:) good idea:)
<thedark>
i cant find lsl in the keyword index...
<thedark>
and is lsl working for big ints?
<mellum>
lsl is for ints only.
<mellum>
Everything except = and < is for one type only.
<thedark>
let k = Random.int (lsl 1 30) in <- syntax error on the " 1 " ...
<mellum>
lsl is infix
<thedark>
oh ok
mrvn has joined #ocaml
mrvn_ has quit [Read error: 110 (Connection timed out)]
<Vincenz>
or
<Vincenz>
((lsl) 1 30)
<Vincenz>
(never mind...only works for symbolix infix operators_
Vincenz has quit [Read error: 104 (Connection reset by peer)]
_ has joined #ocaml
_ is now known as Vincenz
<Vincenz>
hmm
<Vincenz>
question about dualview
<Vincenz>
ugh, I hate it that labels of different records have to have different names
<mellum>
Well, usually you put stuff in different modules, so it's not that bad
<Vincenz>
anyone care to look at some code, it keeps giving me a warning and I don't know why
<mrvn>
Works wonders if you have multiple structures with a prev and next field.
* Vincenz
listens
* mrvn
wonders what he listens for
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
<Vincenz>
mrvn: but you'd have to define each accessor right after the type, right?
clam has joined #ocaml
<seth_>
I have an error message I don't understand. sock is a file_descr, saddr is a sockaddr, but for the statement "Unix.bind sock saddr" I get "This expression has type int -> Unix.file_descr but is here used with type Uhix.file_descr"
<seth_>
but bind has type: file_descr -> sockaddr -> unit
<clam>
seth_: your sock is int -> Unix.file_descr then
<clam>
probably missed an argument somewhere
<seth_>
clam: yes, but why? it is returned by the socket call. No, no missing args.
<clam>
seth_: show me how you obtained it
<seth_>
clam: It's a line I've used before, but maybe there is a flaw in it: val sock = Unix.socket Unix.PF_INET Unix.SOCK_STREAM;
<seth_>
hmm, UnixLabels has a different definition for socket
<seth_>
clam: you are right, it's a partial application.
<clam>
seth_: it's not me, its occam
<seth_>
I wonder why it worked before. :)
<clam>
to quote 'i myself am often surprised at life's little quirks'
<seth_>
hmm, not it doesn't like this: let (cfd,csaddr) = Unix.accept sock
<seth_>
s/not/now/
<clam>
val accept : file_descr -> file_descr * sockaddr
<clam>
is all i can say about it
<seth_>
I'm getting a syntax error. must be in a previous line.
stepcut has joined #ocaml
c1am has joined #ocaml
<seth_>
How do I do a forward reference? I have two classes that need to reference each other.
<Smerdyakov>
The standard solution for normal modules is to functorize one in terms of the other.
<c1am>
Smerdyakov: bullcrap
<c1am>
came up with a signature for those classes
<c1am>
code
<c1am>
profit
<Smerdyakov>
Not exactly that.... you have to break up functionality a wee bit.
<c1am>
again load of bull
<Smerdyakov>
Well, I've done it.
<Smerdyakov>
So ha.
<seth_>
Smerdyakov: explain the issue to me.
<Smerdyakov>
I'm trying to remember the details.
<seth_>
I don't see how signatures will help, since then the signatures will still reference each other.
<seth_>
but, I don't see anything in the docs saying I can use the "functor" statement inside of a class.
<seth_>
or maybe I use it outside the class
<seth_>
the same way as if the module defines functions instead of classes.
<Smerdyakov>
I guess if the signatures reference each other you are in trouble.
<seth_>
I don't see how, if the classes reference each other, the signatures can _not_ reference each other.
<Smerdyakov>
Indeed. I don't ever use OO, so I have no insights into this.
<Smerdyakov>
I do know that it very rarely makes sense to use OO.
<Smerdyakov>
I hope you have a good reason.
<seth_>
that's a separate issue. I still have the forward reference problem even if I don't use classes.
<Smerdyakov>
Why do you want forward reference?
<Smerdyakov>
What modular decomposition are you using where that makes sense?
<seth_>
it's somewhat complicated, but there are many classic software patterns with forward references.
<Smerdyakov>
In functional languages?
<c1am>
create signature for class a, class b
<c1am>
put mutable var in class a of type sig b
<c1am>
likewise for b
<c1am>
d'oh
clam has quit [Read error: 110 (Connection timed out)]
<Smerdyakov>
Most "classic patterns" are hobbled versions of easy functional techniques.
<seth_>
c1am: that's ugly.
<c1am>
seth_: that wroks
<c1am>
works
<seth_>
Smerdyakov: no, I don't agree with that at all. Why are you using ocaml if you hate objects?
<c1am>
cause they suck
<c1am>
slow useless spawns of evil
<Smerdyakov>
seth_, I'm not using OCaml. I may be using OCaml soon, but I really just use SML at the present, and I won't use the O in OCaml if I can help it.
<seth_>
I see no reason not to use it where it makes sense.
<Smerdyakov>
Yes, but you have to justify that it makes sense...
<c1am>
it never makes sense, just take a look at compiler sources
<seth_>
I'm not really an OO person, but it is just foolish to claim that oo is useless.
<c1am>
it's only used in the heart of ocamlopt
<liyang>
c1am: (slowness is not an issue, maintainability _is_. If you want speed go play with assembler. ;)
<c1am>
which means its EVIL
<c1am>
liyang: FUCK YOU
<c1am>
in fact fuck you all
<seth_>
c1am: that's very enlightening.
<Smerdyakov>
seth_, excuse me, but who claimed that OO is useless?
<seth_>
c1am: go back to playing with yourself.
<seth_>
Smerdyakov: c1am
<c1am>
seth_: you think so.. hmm, maybe i will
<Smerdyakov>
Oh. But c1am seems to be installed here solely for entertainment value.
<seth_>
OK :)
<seth_>
can I use a parameterized class for my problem?
<liyang>
(didn't realise the debate was this heated. <g> I think I'll stay out of this one. :o)
<seth_>
liyang: not heated as far as I can see. well, a certain amount of hot air, yes...
<c1am>
geez..
<c1am>
you spoil quite healthy discussion here
<Smerdyakov>
seth_, sounds like no.... but, again, I reaaaally think you should reconsider wanting forward reference!