* Trouble Defining an Object
@ 2005-09-08 18:12 Paul Snively
2005-09-08 20:04 ` [Caml-list] " Gerd Stolpmann
2005-09-08 20:52 ` Jon Harrop
0 siblings, 2 replies; 3+ messages in thread
From: Paul Snively @ 2005-09-08 18:12 UTC (permalink / raw)
To: caml-list
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Folks,
I'm trying to define a class that, given a string containing bytes
from, e.g. an MP3, Ogg Vorbis, etc. music, contains that music.
Later, of course, I'll make the class actually do something with the
data, but for right now I can't even get the code to compile. I'm
using the current ocamlsdl and findlib. Here's a copy of my session
in the ocamlsdl toplevel:
- ----------------------------snip snip----------------------------
Objective Caml version 3.08.4
# #require "sdl.sdlmixer";;
/usr/local/lib/ocaml/site-lib/sdl: added to search path
/usr/local/lib/ocaml/site-lib/sdl/sdlmixer.cma: loaded
# open Sdlmixer;;
# open Filename;;
# class foo init_song =
let name, chan = open_temp_file ~mode:[Open_binary] "foo" "bar" in
output_string chan init_song;
close_out chan;
let the_song = load_music name in
object
val mutable song = the_song
end;;
Characters 123-124:
output_string chan init_song;
^
Syntax error
- ----------------------------snip snip----------------------------
I'm at a loss to understand where the error lies. Any advice would be
greatly appreciated.
Many thanks and best regards,
Paul
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)
iEYEARECAAYFAkMgfwcACgkQO3fYpochAqKSnQCgtaAHbn6WNPyBf5dymt+E2l8n
IzEAoIzGA4Xb5igB719KOf/msuEBG/wD
=HlQ/
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Trouble Defining an Object
2005-09-08 18:12 Trouble Defining an Object Paul Snively
@ 2005-09-08 20:04 ` Gerd Stolpmann
2005-09-08 20:52 ` Jon Harrop
1 sibling, 0 replies; 3+ messages in thread
From: Gerd Stolpmann @ 2005-09-08 20:04 UTC (permalink / raw)
To: Paul Snively; +Cc: caml-list
That's a purely syntactic issue. Instead of
class foo =
expr1;
expr2;
object ... end
use:
class foo =
let () = expr1 in
let () = expr2 in
object ... end
Only "let var = expr in expr" may be used between "class" and "object".
Gerd
Am Donnerstag, den 08.09.2005, 11:12 -0700 schrieb Paul Snively:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Folks,
>
> I'm trying to define a class that, given a string containing bytes
> from, e.g. an MP3, Ogg Vorbis, etc. music, contains that music.
> Later, of course, I'll make the class actually do something with the
> data, but for right now I can't even get the code to compile. I'm
> using the current ocamlsdl and findlib. Here's a copy of my session
> in the ocamlsdl toplevel:
> - ----------------------------snip snip----------------------------
> Objective Caml version 3.08.4
>
> # #require "sdl.sdlmixer";;
> /usr/local/lib/ocaml/site-lib/sdl: added to search path
> /usr/local/lib/ocaml/site-lib/sdl/sdlmixer.cma: loaded
> # open Sdlmixer;;
> # open Filename;;
> # class foo init_song =
> let name, chan = open_temp_file ~mode:[Open_binary] "foo" "bar" in
> output_string chan init_song;
> close_out chan;
> let the_song = load_music name in
> object
> val mutable song = the_song
> end;;
> Characters 123-124:
> output_string chan init_song;
> ^
> Syntax error
> - ----------------------------snip snip----------------------------
>
> I'm at a loss to understand where the error lies. Any advice would be
> greatly appreciated.
>
> Many thanks and best regards,
> Paul
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (Darwin)
>
> iEYEARECAAYFAkMgfwcACgkQO3fYpochAqKSnQCgtaAHbn6WNPyBf5dymt+E2l8n
> IzEAoIzGA4Xb5igB719KOf/msuEBG/wD
> =HlQ/
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de
Telefon: 06151/153855 Telefax: 06151/997714
------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Trouble Defining an Object
2005-09-08 18:12 Trouble Defining an Object Paul Snively
2005-09-08 20:04 ` [Caml-list] " Gerd Stolpmann
@ 2005-09-08 20:52 ` Jon Harrop
1 sibling, 0 replies; 3+ messages in thread
From: Jon Harrop @ 2005-09-08 20:52 UTC (permalink / raw)
To: caml-list
On Thursday 08 September 2005 19:12, Paul Snively wrote:
> # #require "sdl.sdlmixer";;
> /usr/local/lib/ocaml/site-lib/sdl: added to search path
> /usr/local/lib/ocaml/site-lib/sdl/sdlmixer.cma: loaded
> # open Sdlmixer;;
> # open Filename;;
> # class foo init_song =
> let name, chan = open_temp_file ~mode:[Open_binary] "foo" "bar" in
> output_string chan init_song;
> close_out chan;
> let the_song = load_music name in
> object
> val mutable song = the_song
> end;;
Perhaps you want:
class foo init_song =
let name, chan = open_temp_file ~mode:[Open_binary] "foo" "bar" in
let () =
output_string chan init_song;
close_out chan in
let the_song = load_music name in
object
val mutable song = the_song
end;;
or even:
let foo init_song =
let chan = open_out "foo" in
let () =
output_string chan init_song;
close_out chan in
let the_song = load_music name in
object
val mutable song = the_song
end;;
But I'm not sure...
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-09-08 20:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-08 18:12 Trouble Defining an Object Paul Snively
2005-09-08 20:04 ` [Caml-list] " Gerd Stolpmann
2005-09-08 20:52 ` Jon Harrop
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox