<LittleDa1>
so those have to be at compiletime to preserve static typing, right?
<Riastradh>
They have to be at compile-time because they play a role in the module system.
<LittleDa1>
oh
<LittleDa1>
and modules have to be compiletime to preserve static typing or something else?
<LittleDa1>
because IIRC modules are runtime in Python
<Riastradh>
Python's architecture is not designed to operate well with static compilation.
<LittleDa1>
It seems like each programming language has a completely different concept of modules
<Riastradh>
Most programming languages themselves are pretty different.
<LittleDa1>
So do functors accomplish something similar to Ruby's use of modules as mixins, but in a less dangerous, more efficient, and more module-oriented way?
<Riastradh>
And aside from the aqueducts, the roads, et cetera as well?
<LittleDa1>
what?
<Riastradh>
Monty Python reference.
<LittleDa1>
which one
<Riastradh>
_Life of Brian_
<LittleDa1>
so is that statement correct?
<Riastradh>
What statement?
<LittleDa1>
Are functors analogous to mixins in Ruby?
<Riastradh>
That's an interrogative, not a declarative; a question, not a statement.
<LittleDa1>
Functors are analogous to mixins in Ruby.
<LittleDa1>
better?
<Riastradh>
Given that I'm not very familiar with Ruby, I can't say.
<LittleDa1>
ok
<Smerdyakov>
LittleDa1, are mixins related to multiple inheritance?
<LittleDa1>
yes, but you're including a module, and it's expected that you have certain functions implemented in the class
<Smerdyakov>
Functors are not related to multiple inheritance.
<Smerdyakov>
Please, just read the manual.
<LittleDa1>
I know they're not related to multiple inheritance
<LittleDa1>
but they are used in similar situations
<LittleDa1>
I read the manual
<Smerdyakov>
OK
<Smerdyakov>
To me, it's clear that "expecting to have some things implemented" is a lot worse than having a type system enforce proper use of functors.
<LittleDa1>
I know, it's very dangerous
<LittleDa1>
but somewhat simpler
<Smerdyakov>
Not simpler to code, since there are more possibilities for confusing errors.
<LittleDa1>
I haven't had much trouble debugging Ruby; you rarely make errors of that sort. I don't want to get in a big debate about typesaftey, though
wazze has quit ["--- reality is that which, when you stop believing in it, doesn't go away ---"]
Lemmih has joined #ocaml
cjohnson has joined #ocaml
cjohnson has quit ["Drawn beyond the lines of reason"]
cjohnson has joined #ocaml
housetier has quit ["#breaks @ irc.highteq.de"]
themus has joined #ocaml
reltuk has joined #ocaml
kinners_ has quit ["leaving"]
bk_ has quit ["I'll be back"]
reltuk has left #ocaml []
mrsolo has joined #ocaml
gim has joined #ocaml
mrsolo has quit [Read error: 104 (Connection reset by peer)]
Banana has quit [Read error: 104 (Connection reset by peer)]
reltuk has joined #ocaml
mrsolo has joined #ocaml
__DL__ has joined #ocaml
bk_ has joined #ocaml
__DL__ has quit [Read error: 104 (Connection reset by peer)]
Jaundice has joined #ocaml
mrsolo has quit [Read error: 54 (Connection reset by peer)]
mrsolo has joined #ocaml
SpookRijder has joined #ocaml
smimou has joined #ocaml
smimou has quit [Remote closed the connection]
smimou has joined #ocaml
reltuk has left #ocaml []
Banana has joined #ocaml
mijdrol has quit [Read error: 110 (Connection timed out)]
mijdrol has joined #ocaml
<slashvar[lri]>
Hi
<Banana>
Hello.
<gl>
Hu.
<bk_>
hello
buggs^z has joined #ocaml
buggs has quit [Read error: 60 (Operation timed out)]
mrsolo has quit ["Leaving"]
slashvar[lri] is now known as slashvar[kf]
Jaundice has quit ["Leaving"]
SpookRijder has quit ["Client Exiting"]
slashvar[kf] is now known as slashvar[typage]
kinners has joined #ocaml
LordBrain has joined #ocaml
<LordBrain>
Hello, i am a beginner in ocaml. For writing a simple program which accepts connections on a given port on a network, what module should i use and read?
<LordBrain>
someone remind me.. what operator is string concatenation?
<mof>
^
<LordBrain>
ok, thanks
<mof>
IIRC, I'm a beginner too. :-)
<mof>
(It seems to be correct however.)
<Snark>
it is
Demitar has quit [Remote closed the connection]
Demitar has joined #ocaml
pattern has quit [Read error: 110 (Connection timed out)]
<mof>
Why do I get the following when running ocaml interactively:
<mof>
# Graphics.open_graph "640x480";;
<mof>
Reference to undefined global `Graphics'
<Banana>
yes.
<Banana>
Graphics library is not linked by default.
<mof>
Ah.
<Banana>
it is not part of the standard library.
<Banana>
ocamlmktop -o ocamlgraphics graphics.cma
<Banana>
and use ocamlgraphics as you interractive toplevel instead of ocaml.
<mof>
Oh, thanks.
wazze has joined #ocaml
Lemmi1 has joined #ocaml
karryall has joined #ocaml
Lemmih has quit [Read error: 110 (Connection timed out)]
<LordBrain>
is there a difference between using "let a=3 and b=5 in" and using "let a=3 in let b=5 in" ?
yella has joined #ocaml
<karryall>
LordBrain: evaluation order is unspecified in the first case
<LordBrain>
ah i see, thanks
<mattam>
also you can't use a in the definition of b in the first case
Lemmi1 is now known as Lemmih
<mattam>
except with let rec a ...
<LordBrain>
ok
<mof>
Hm, why do I get the following when I try to open_graph "640x480" in the ocaml toplevel?
<mof>
Exception: Graphics.Graphic_failure "Cannot open display 640x480".
<andrewb>
You need a space preceding the geometry
<andrewb>
see the examples in the manual
<mof>
Oh! I missed that :-) Ty.
karryall has quit ["tcho"]
maihem has joined #ocaml
maihem has quit [Read error: 104 (Connection reset by peer)]
smimou has quit ["J'ai fini."]
<LordBrain>
"This function uses the auxiliary function domain_of, which extracts the domain of a socket from its address." -- I'm looking at a book on ocaml with an example server, but i dont see the source to this domain_of function anywhere.. is that in a library somewhere?
<LordBrain>
How do i tell vim to use spaces for tabs?
<gl>
"TA GUEULE !!!" :)
<LordBrain>
oops wrong room
mattam_ is now known as mattam
Jaundice has joined #ocaml
<Snark>
hmmmm...
<Snark>
I have a defs.ml, a something_parser.mly ad a something_lexer.mll ; the two latest would need to "include" the first
<LordBrain>
Here is a style question... I have a 2 line function which is only called from within another 2 line function and neednt be global, so i could include it in a let within the definition of the other function, but i think it might be more readable if i keep it separate. In your opinion(s), is it better to keep it separate or to embed it?
<det>
God damn caml-list is active
<Banana>
det: yeah you bet.
<Banana>
stupid question about an "eval" function a la python.
<Banana>
LordBrain: in term of performance, it's the same.
<Banana>
(quite the same).
<LordBrain>
well it seems like its a question of scope verses readability
<Banana>
so nesting the function is cleaner.
<Riastradh>
Use whichever one you prefer.
<Banana>
but you can also hide it by a module signature so it's not a big problem to keep them separate.
<LordBrain>
hmm readability is probably more important
det has quit ["Hey! Where'd my controlling terminal go?"]
<Snark>
good night
Snark has left #ocaml []
det has joined #ocaml
malte has joined #ocaml
pattern has joined #ocaml
srv has quit [Read error: 104 (Connection reset by peer)]
srv has joined #ocaml
cjohnson has quit [Read error: 104 (Connection reset by peer)]
cjohnson has joined #ocaml
bk_ has joined #ocaml
LittleDan has joined #ocaml
<LittleDan>
Why doesn't OCaml use equality types like SML?
<Riastradh>
Equality types are a brusquely tacked-on-at-the-last-minute extension to the type system to half-assedly support operator overloading for equality comparison.
<LittleDan>
but OCaml has runtime exceptions for type errors, isn't that worse?
<Riastradh>
Run-time type errors?
<mattam>
aren't type errors unspecified at runtime ?
<LittleDan>
for being unable to check for equality, I think
<LittleDan>
I'm probably mistaken
<LittleDan>
as you could probably guess, I'm a beginner
<mattam>
there is no type information at runtime, so type errors go uncatched until... not long :)
<mattam>
what are equality types ?
<Riastradh>
SML's hideousy for generic equality comparison.
<LittleDan>
Does not have equality type variables - comparison allowed on all types but may raise Invalid_argument exception
<LittleDan>
I prefer typeclasses for this sort of thing, but I can't find any strict functional language with typeclasses
<Riastradh>
Implement 'em!
<LittleDan>
You mean a language?
<Riastradh>
No, I mean implement typeclasses in OCaml.
<LittleDan>
You mean make something like Haskell's typeable?
<LittleDan>
Or make explicit type constructors for everything, which can then be used to pattern match based on type?
<Riastradh>
No, I mean implement typeclasses in OCaml.
<LittleDan>
You mean modify the base system?
<Riastradh>
Yes.
<LittleDan>
But wouldn't that require completely redoing the type system>
<LittleDan>
I think
<Riastradh>
Why don't you try it and find out?
<mattam>
:)
<LittleDan>
Ocaml is implemented in C, right?
<Riastradh>
The run-time system is implemented in C and the compilers are implemented in OCaml.
<LittleDan>
I've tried to learn C so many times but I'm just terrible at low-level languages
<Riastradh>
You'd be modifying OCaml code, not C.
<LittleDan>
I'm trying to make my own language right now, which is why I'm learning OCaml
<LittleDan>
but you need runtime type information for typeclasses, don't you?
<Riastradh>
No. Type dispatch can be resolved at compile-time.
<LittleDan>
You mean like in Java?
<Riastradh>
?
<LittleDan>
Their generic functions
<LittleDan>
functions for different types have different signatures
<Riastradh>
I am unfamiliar witih Java's generic functions.
<Riastradh>
With, even.
<LittleDan>
they're really completely different functions
<LittleDan>
pretty bad for generic type dispatch
<mattam>
this is done at runtime in java
<LittleDan>
really?
<LittleDan>
How does it work, then?
<mattam>
you mean specialization right ?
<mattam>
like f(int) and f(double)
<LittleDan>
yeah
<LittleDan>
that's runtime?
<mattam>
the method call is at runtime, and the decision may be dependant on the called values
<LittleDan>
Why do that when you have static typing as inflexibly as Java has?
<LittleDan>
why isn't it done at compiletime?
<mattam>
wait a second, i may be mistaken
<Riastradh>
Ask Java's designers.
<mattam>
like if you have an object of A which has two subclasses B and C, and f(A), f(B) and f(C) are defined. I'm not sure
<LittleDan>
that's different than f(int) and f(double), since int and double aren't classes, right?
<LittleDan>
runtime class information is different than runtime type information (at least in Java)
<LittleDan>
So how can type dispatch be resolved at compiletime, riastradh?
<LittleDan>
unless you have a different function stored for each instance of the typeclass
<Riastradh>
Uh, how do you expect to do it _without_ doing that?
<LittleDan>
It's obvious how runtime typing systems work (since there are so many examples), but how would it work at compiletime? If it dispatches on the type, and the function can accept different types, how isn't that a runtime property?
<LittleDan>
You can still have static typechecking even if there's runtime type information
<Riastradh>
No, because all types are decidable at compile-time with OCaml's strict, static type system.
<LittleDan>
no, the type information is only used internally
<Riastradh>
?
<LittleDan>
to determine how to dispatch on the type
<Riastradh>
?
<LittleDan>
maybe I have this whole conception of structured polymorphism wrong
Jaundice has quit ["Leaving"]
<Riastradh>
Please form a complete sentence that explains the entirety of what you mean. 'To determine how to dispatch on the type' makes no sense to me.
reltuk has joined #ocaml
<LittleDan>
I thought the function internally looked at the type of its argument and chose what to do based on that.
<reltuk>
has there been any traffic on the news group in the last day? I don't think I subscribed, but I thought I did
<LittleDan>
not much, just check google news
<LittleDan>
or something similar
<Riastradh>
No, LittleDan, because a) there's no run-time type information, and b) all types are decidable at compile-time, so there's no need to.
<reltuk>
yeah, I didn't get anything in fa.list
<LittleDan>
Riastradh: I know, but I'm wondering how structured polymorphism (which, I think, is like typeclasses) can be implemented without runtime type information
<LittleDan>
You said it could
<LittleDan>
I'm not talking about OCaml as it currently is
<LittleDan>
because it doesn't have typeclasses
<Riastradh>
All types are decidable at compile-time, so with that information, you perform the dispatch at compile-time.
<reltuk>
even with typeclasses the type information is decidable at compile time, right?
<LittleDan>
how do you do that when you have functions (in this theoretical OCaml hack) like
<LittleDan>
(=) : Eq 'a => 'a -> 'a -> bool
<LittleDan>
and this might be in a module where not all instances of Eq are knowable at compiletime
<LittleDan>
reltuk: How? That's what I'm trying to ask
<reltuk>
the module is distributed in source form
<reltuk>
there's been research into distributing in binary form...just basically no one does it
<Riastradh>
All you need to do is dump the type information as well as the code, reltuk.
<LittleDan>
apt-get distributes OCaml modules in binary form
<LittleDan>
that's type information after compiletime, isn't it?
<LittleDan>
(oh, but modules have that, I forgot)
<Riastradh>
No, because only the compiler uses it.
<reltuk>
Riastradh: he's saying functions that had been compiled which use Eq wouldn't dispatch correctly
<reltuk>
and he's right...it's like distributing STL in source form
<reltuk>
let me see if I can't find that paper I read on distributing them in binary..
<LittleDan>
So would something like that have a different function implemented for each instance of Eq?
<reltuk>
a different compiled function, yes
<reltuk>
it's the same in source form
<LittleDan>
Doesn't that make excessively large binaries?
<reltuk>
not really...it's only compiled for types that it's used with
<LittleDan>
but what if it's in a module distributed in binary?
<LittleDan>
Would it have to be in a bytecode?
<reltuk>
it's the exact same size as if you had implemented the functionality seperately
<LittleDan>
Is that how Haskell does it?
<reltuk>
it could be in real-machine code or bytecode...don't see how it makes a difference
<LittleDan>
byte-code might store some higher-level information about typeclasses
<reltuk>
haskell distributes libraries in source form...
<reltuk>
at least, standard libraries that come with the compiler
<LittleDan>
if you did something like
<LittleDan>
f : Eq 'a, 'b => 'a -> 'b -> unit
<LittleDan>
then wouldn't the size of the executable increace exponentially by the number of types you use?
<reltuk>
LittleDan: yes, but it's not more code than would be necessary to implement the functionality anyways...
<Riastradh>
GHC dumps types and code to separate files.
<reltuk>
if you need code in the program to compare two binary trees, you need it in...doesn't matter if it makes the code any bigger
<LittleDan>
Oh, so if I wanted to implement typeclasses in OCaml, it could be as simple as a preprocessor? (what am I saying? that's not simple)
<LittleDan>
but it's simpler
<reltuk>
all I know is that the very smart people that implemented ghc said Haskell's type system was much much harder to get right than a basic Hinley-... (brain fart, what OCaml ahs)
<LittleDan>
so it's like an annoying implicit super all the time in Java?
<reltuk>
java is annoying in general :-p
<LittleDan>
At the high school I go to, they teach Java as a first programming language. I can't think of anything worse.
<reltuk>
I can...at the college I go to, they do the same thing
<LittleDan>
I mean I can't think of any language worse.
<reltuk>
of course, the goal isn't to teach Java...but they use it to teach people the fundamentals of algorithms
<LittleDan>
then why not use a functional language?
<reltuk>
which is absolutely disgusting...they used to use scheme, which should have been much better for teaching algorithms in my opinion
<mattam>
they do the same in my university, but the next year, we write a Java compiler in OCaml and are encouraged to criticize it to learn how to make good(c) languages.
<LittleDan>
each student writes a full java compiler?
<mattam>
that is done in binomials(?)
<reltuk>
we never touch java again after first semester
<mattam>
and only a subset of java (no packages, threads, interfaces, arrays (although i did arrays for fun :)))
<reltuk>
and most people don't write their first compiler until junior or senior year
<LittleDan>
you get to writing compilers as an undergrad?
<reltuk>
actually, most people don't write a compiler at all
<reltuk>
that class isn't a required undergrad class
<reltuk>
LittleDan: you can always write whatever you want :-p
<LittleDan>
I know, but the college has you take that class
<mattam>
hey, you're 20 at this time, that's a good time to write a compiler
<reltuk>
LittleDan: well, most colleges will have a person take a class on programming languages, theories and choices made in designing one, parsing, etc...
<reltuk>
LittleDan: for the most part, these classes have you write interpreters for languages, not compilers...
<mattam>
i'm not sure i was undergrad, is undergrad anything before a master ?
<reltuk>
mattam: undergrad is when you're pursuing a BS