<atkin>
hello all. I am learning to use ocaml, and am getting a type error. would anyone mind helping me out?
<Smerdyakov>
More detail would allow anyone who is watching to attempt answering your question.
Nutssh has quit ["Client exiting"]
<atkin>
ok, declaring two classes in one statement, using "and". At the start of the second class, I'm getting an error saying "the abbreviation chromosome expands to type ... but is used with type ...
<atkin>
seen this before, but not with "abbreviation"
<Smerdyakov>
Declarations using the "class" keyword expand to a more basic form.
<Smerdyakov>
Unlike in Java or C++, a class type is defined only by the signatures of the methods it has.
<Smerdyakov>
So, for instance, the following are equivalent:
<Smerdyakov>
class a = object method (x:int) = x end
<Smerdyakov>
errr...
<Smerdyakov>
class a = object method m (x:int) = x end
<Smerdyakov>
and
<Smerdyakov>
type a = < m : int -> int >
<Smerdyakov>
OK, that actually was wrong.
<Smerdyakov>
If the class definition were "class type a = ..."
<Smerdyakov>
Then it would be right.
<atkin>
oh, that makes it a little clearer
<atkin>
what I'm trying to figure out is what an abbreviation is
<Smerdyakov>
I'm guessing that the abbreviation is for the type associated with a class you are defining.
<atkin>
oh.
* indigo
humms
<atkin>
well, that does make some sense. looks like I may be getting somewhere. thanks a lot.
yeoh has left #ocaml []
<atkin>
oops, used to the C++/Perl/Java. stuck a semicolon in there.
<atkin>
how do you get a val from another class of the same type?
<Smerdyakov>
What?
<atkin>
such as I have "class a = object val v; method m (o: a) ..." and I want method m to access o's a. Do I use . or # or do I need to make a method?
<atkin>
actually, o's "v"
<Smerdyakov>
I think you need to make a method. val's are entirely private.
<atkin>
sweet. thanks.
YveDeLarc has quit [Read error: 60 (Operation timed out)]
YveDeLarc has joined #ocaml
reltuk has joined #ocaml
phj___ has joined #ocaml
phj___ is now known as phj
reltuk has quit ["Leaving"]
phj has quit [Read error: 110 (Connection timed out)]
Jaundice has joined #ocaml
evil-eddie has joined #ocaml
YveDeLarc has quit [Remote closed the connection]
The-Fixer has quit ["Goodbye"]
Godeke_ has quit [Client Quit]
Godeke has joined #ocaml
phj___ has joined #ocaml
phj___ is now known as phj
kinners has quit ["leaving"]
evil-eddie has left #ocaml []
Jaundice has quit [Client Quit]
Jaundice has joined #ocaml
whee has joined #ocaml
mrsolo has joined #ocaml
LordJ|m has quit [Read error: 104 (Connection reset by peer)]
Nutssh has joined #ocaml
Jaundice has quit [Client Quit]
atkin has quit [Read error: 110 (Connection timed out)]
gim has joined #ocaml
mrsolo has quit [Read error: 60 (Operation timed out)]
phj has quit ["no reason"]
gim has quit [Read error: 60 (Operation timed out)]
gim has joined #ocaml
Waco_Jesus has quit ["I'll be back"]
wazze has joined #ocaml
Nutssh has quit ["Client exiting"]
TachYon26 has joined #ocaml
wazze is now known as wegzze
wegzze has quit [Read error: 104 (Connection reset by peer)]
bk_ has joined #ocaml
marcpula is now known as marcla
marcla is now known as mulder
mulder is now known as marcmeuh
mattam_ has joined #ocaml
mattam has quit [Client Quit]
bk_ has quit ["I'll be back"]
Nutssh has joined #ocaml
phj has joined #ocaml
TachYon26 has quit [Read error: 110 (Connection timed out)]
Nutssh has quit ["Client exiting"]
cjohnson has quit [wells.freenode.net irc.freenode.net]
slashvar[lri] has quit [wells.freenode.net irc.freenode.net]
Hipo has quit [wells.freenode.net irc.freenode.net]
gl has quit [wells.freenode.net irc.freenode.net]
cmeme has quit [wells.freenode.net irc.freenode.net]
TachYon26 has joined #ocaml
cjohnson has joined #ocaml
slashvar[lri] has joined #ocaml
Hipo has joined #ocaml
gl has joined #ocaml
cmeme has joined #ocaml
mattam_ is now known as mattam
bk_ has joined #ocaml
__DL__ has joined #ocaml
__DL__ has quit [Client Quit]
TachYon26 has quit [Remote closed the connection]
marcmeuh has quit [Read error: 60 (Operation timed out)]
<pflanze>
It gives Syntax error at line 9 characters 42-44
<Demitar>
Well try removing the double semicolon to begin with.
<pflanze>
It then complains at the end of the file
<Demitar>
Second as a matter of programming style you probably want to curry the function arguments.
<pflanze>
curry?
<pflanze>
That belongs into thai food.
<pflanze>
Seriously, I don't even know what that means.
<vegai>
that would be "let rec lieszeile linecount charcount" instead of what you have
<Demitar>
let rec lieszeile linecount charcount = ...
<pflanze>
Ah.
<Riastradh>
[[(f x) y]] versus [[f (x, y)]].
<pflanze>
Yep but I could not get it to work this way.
<pflanze>
ah, (f x) y sounds interesting.
<Riastradh>
[[(f x) y]] is just [[f x y]] with associativity made explicit.
<pflanze>
Like this? (file changed)
<pflanze>
still gives syntax error
<Demitar>
pflanze, let ic = open_in "../../cppdev_mount/httpd-logparser/bigloo/access.log.0";;
<pflanze>
ok that works now.
<Demitar>
Then again, I never liked toplevel assignments.
<Riastradh>
It's not an assignment, Demitar.
<Demitar>
Yes yes I know.
<bk_>
.oO( application from left to right )
<pflanze>
That was the same reasoning I had to use 'in'.
<Demitar>
pflanze, the other solution would be to use let ... in with both bindings.
<pflanze>
which two bindings?
<vegai>
Demitar: what don't you like about those?
* pflanze
doesn't like to pollute namespaces - pro lamdas :)
<Demitar>
vegai, to begin with my brain is churning a bit slowly at the moment. But basically it's too easy to start making global bindings which remind too much of C global variables.
<Riastradh>
Demitar, it's pretty hard to write useful programs that don't have any global variables; _EVERYTHING_ must be done locally inside 'let ... in ...'s.
<Riastradh>
_Mutable_ global variables are an _entirely_ different issue.
<Riastradh>
And none of pflanze's global variables in that program were mutable.
<Demitar>
Riastradh, yes, I was merely too tired to make that distinction. =)
<Demitar>
Riastradh, a channel isn't exactly immutable. =)
<Riastradh>
The _value_ may be mutable, but that isn't the same as the _variable_ being mutable. (I count variables that contain references as being mutable because generally the sole purpose of using references is for their mutability.)
<Demitar>
But they're not _variables_ (as you said earlier). =)
<Riastradh>
?
<Demitar>
They are bindings. Even if they bind to a ref it's still the value being mutable. =)
<pflanze>
Hm, how does one get the length of a string? str.length does not work, a function does not seem to exist?
<Riastradh>
Changing the name from 'variable' to 'binding' simply because it is a common misconception that 'variable' implies 'mutable variable' is so silly that I refuse to accept such a change.
<Demitar>
Riastradh, but do ignore me right now since I'm too tired to produce any useful thoughts. :)
* pflanze
thinks that variables are variable
<Demitar>
pflanze, String.length "foo"
<Riastradh>
'Variable' (as an adjective) is _not_ synonymous with 'mutable.'
<pflanze>
D'oh, why not "foo".length??
<Riastradh>
Why "foo".length?
<Demitar>
pflanze, since it's not python "everything is an object with runtime bindings".
<pflanze>
(hm ok, I prolly misread the book in a way that I thought method invocation looks like in java )
<Demitar>
pflanze, it generally has to do with type inference really.
<pflanze>
has to do, hm
<pflanze>
Hope it's cleaner than in lisp.
<Riastradh>
?
<Riastradh>
What is 'it' there?
<pflanze>
Lisp has generic functions that dispatch on the type of arguments.
<Demitar>
LISP is dynamically typed.
<Riastradh>
Generic functions are inherently unclean?
<pflanze>
Which would be wonderful if it didn't have the restriction that all same-named methods have the same number of arguments.
<pflanze>
So you generally have to fully qualify the method instead of importing it.
<Smerdyakov>
Why is that bad?
<pflanze>
So it looks just like String.length str
<Demitar>
Yes.
<pflanze>
Because I hate typing.
<pflanze>
My-Some-Packagetype-Subtype.length var
<pflanze>
And also because it's not generic anymore then.
<Demitar>
If you want let (=^) s = String.length s.
<Demitar>
Then you can do =^ str. =)
<Demitar>
pflanze, you do less typing than you think really.
<Demitar>
Generally you make powerful use of the functional paradigms and list processing.
<pflanze>
Hmm, my program is not tail-recursive?
<pflanze>
It gets a stack overflow.
<pflanze>
What do I have to modify?
<Smerdyakov>
Probably make it tail-recursive..?
<pflanze>
(current version uploaded)
<pflanze>
"But it is already"?
<pflanze>
Hm
<pflanze>
it enters a try on every invocation, ok, that's probably hard to optimize away.
<Smerdyakov>
Function calls inside try are never tail recursive.
<pflanze>
Wow, it's real real fast now.
srv_ has joined #ocaml
srv has quit [Read error: 104 (Connection reset by peer)]
srv_ is now known as srv
srv has quit [Client Quit]
Jaundice has joined #ocaml
Jondice has joined #ocaml
Jondice has quit [Client Quit]
Jaundice has quit [Client Quit]
Jaundice has joined #ocaml
<pflanze>
(It's 49 times faster than C++, 4.8 times faster than Sun Java, 1.56 times faster than perl, and 0.17 times wc -l -c; all only cpu times, on a 290mb file)
<malte>
49 times faster than c++?!
<pflanze>
(Forgot bigloo: ocamlopt program is 0.60 times as fast as bigloo.)
<pflanze>
Yep, I'm also baffled by the poor C++ performance.
<pflanze>
That's when using std::string and getline().
<vegai>
what compiler?
<pflanze>
gcc 3.3.2
<vegai>
with some optimization, right?
<pflanze>
-O8
<vegai>
so -O3
<pflanze>
It's the std:: libraries that seem dead slow.
<vegai>
yeah, they might
srv has joined #ocaml
<pflanze>
I've timed malloc, and it looks like getline -> std::string does multiple mallocs for every line.
<vegai>
but, of course, we already knew that ocaml is fast ;)
<pflanze>
If malloc is the problem.
<pflanze>
I'm writing a log parser, and ended up rewriting the C++ version not to use getline and string but C's getc() instead.
<pflanze>
That made it 10 times faster.
<pflanze>
All in all a horrible experience for me as a rather C++ newbie.
<pflanze>
BTW string.append() is escpecially horrible, for the places where I needed std::string I ended up allocating a char buf[] on the stack, filling that with getc(), then .assign() that to the string.
<pflanze>
I also tried wxString (from wxWindows) instead of std::string, but that was even about 5 times slower.
<vegai>
yeah, obviously a C++-guru would be able to hack it faster
<vegai>
to be faster, that is
<pflanze>
Hope so, but then I don't know how he would do it using std:: stuff. I can only imagine it making faster when writing own string classes etc.
<pflanze>
I mean, a string that when calling .append() spends as much time as malloc'ing a whole new string each time can't be real?.. but looks so.
<Hadaka>
pflanze: string.reserve(size) - and a bunch of other things
<Demitar>
And stl rope if you're doing lots of that.
<pflanze>
Thanks for that tip, Demitar, I looked it up. It's still repellent for me that the default C++ stuff is so slow, when the default implementations in languages like ocaml/bigloo/even perl seem fine.
<pflanze>
Looks like C++ is really costly programmer-time wise.
<pflanze>
Can you mix ocamlopt-compiled stuff, bytecode and the interpreter nicely?
<pflanze>
Or rather: can you build a running application so that you can hook up to it and modify it interactively, like you can do in lisps?
Octoploid has joined #ocaml
pflanze has quit ["cu"]
Octoploid has quit ["leaving"]
maihem has quit ["Client exiting"]
mimosa has joined #ocaml
malte is now known as foobarer
foobarer is now known as malte
nullboy_ has joined #ocaml
<nullboy_>
greetings
<malte>
good evening
<nullboy_>
I extended stdlib with the possibility (under linux) to install signal handlers that accept a "code" value as well as the signal number
<nullboy_>
I wanted to see what ppl thought of making that part of the distributed version of ocaml
gim has quit []
Jaundice has quit [Client Quit]
mlh has joined #ocaml
wazze has quit ["--- reality is that which, when you stop believing in it, doesn't go away ---"]
Riastradh has quit [Read error: 60 (Operation timed out)]