* [Caml-list] Problem with classes or i need help
@ 2003-02-05 21:40 inv2002
2003-02-05 16:31 ` [Caml-list] Ugly fonts in ocamlbrowser/editor Wai-Sun Chia
2003-02-06 0:44 ` [Caml-list] Problem with classes or i need help Jacques Garrigue
0 siblings, 2 replies; 7+ messages in thread
From: inv2002 @ 2003-02-05 21:40 UTC (permalink / raw)
To: caml-list
I don't know correct solution of my problem.
Here my example:
---begin 1.ml---
#!/usr/bin/env ocamltop
class virtual figure () =
object
method virtual to_string: string
end
class triangle () =
object
inherit figure ()
method private to_string = "Triangle"
method m1 = Random.float 5.0
end
class circle () =
object
inherit figure ()
method private to_string = "Circle"
method m2 = Random.int 6
end
class screen () =
object
val mutable figures = []
method add_figure f =
figures <- (f#to_string ) :: figures
end
let main () =
let s1 = new screen () in
s1#add_figure (new circle ());
s1#add_figure (new triangle ())
let () = main ()
--end---
[inv@localhost ~]$ ./1.ml
File "./1.ml", line 22, characters 5-121:
Some type variables are unbound in this type:
class screen :
unit ->
object
val mutable figures : 'a list
method add_figure : < to_string : 'a; .. > -> unit
end
The method add_figure has type < to_string : 'a; .. > -> unit where ..
is unbound
I understand the problem, but i don't know solution, help, please.
--
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Caml-list] Ugly fonts in ocamlbrowser/editor
2003-02-05 21:40 [Caml-list] Problem with classes or i need help inv2002
@ 2003-02-05 16:31 ` Wai-Sun Chia
2003-02-06 6:35 ` Jacques Garrigue
2003-02-06 0:44 ` [Caml-list] Problem with classes or i need help Jacques Garrigue
1 sibling, 1 reply; 7+ messages in thread
From: Wai-Sun Chia @ 2003-02-05 16:31 UTC (permalink / raw)
To: caml-list
Hello lists,
Newbie here, just successfully installed ocaml-3.06 on my Redhat box.
Was testing out labltk and ocamlbrowser and found that both the browser
and editor uses the ugliest monospace font ever..
Any clues to how to change the default font for all labltk's
applications? Or perhaps this is a tk issue?
--
Wai-Sun "Squidster" Chia
Techinical Consultant
Consulting & Integration
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Problem with classes or i need help
2003-02-05 21:40 [Caml-list] Problem with classes or i need help inv2002
2003-02-05 16:31 ` [Caml-list] Ugly fonts in ocamlbrowser/editor Wai-Sun Chia
@ 2003-02-06 0:44 ` Jacques Garrigue
2003-02-14 15:33 ` inv2002
1 sibling, 1 reply; 7+ messages in thread
From: Jacques Garrigue @ 2003-02-06 0:44 UTC (permalink / raw)
To: inv2002; +Cc: caml-list
> class virtual figure () =
> object
> method virtual to_string: string
> end
[...]
> class screen () =
> object
> val mutable figures = []
> method add_figure f =
> figures <- (f#to_string ) :: figures
> end
[...]
> The method add_figure has type < to_string : 'a; .. > -> unit where ..
> is unbound
>
> I understand the problem, but i don't know solution, help, please.
Are you sure you understood ?-)
There's nothing in your program to tell the compiler that the argument
to add_figure is supposed to be a figure.
method add_figure (f : figure) =
figures <- f#to_string :: figures
Or, if you want to avoid coercions when calling #add_figure,
method add_figure : 'a. (#figure as 'a) -> unit = fun f ->
figures <- f#to_string :: figures
Jacques Garrigue
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Problem with classes or i need help
2003-02-06 0:44 ` [Caml-list] Problem with classes or i need help Jacques Garrigue
@ 2003-02-14 15:33 ` inv2002
2003-02-15 7:02 ` Jacques Garrigue
0 siblings, 1 reply; 7+ messages in thread
From: inv2002 @ 2003-02-14 15:33 UTC (permalink / raw)
To: garrigue; +Cc: inv2002, caml-list
>> class virtual figure () =
>> object
>> method virtual to_string: string
>> end
>[...]
>> class screen () =
>> object
>> val mutable figures = []
>> method add_figure f =
>> figures <- (f#to_string ) :: figures
>> end
>[...]
>> The method add_figure has type < to_string : 'a; .. > -> unit where ..
>> is unbound
>>
>> I understand the problem, but i don't know solution, help, please.
>
>Are you sure you understood ?-)
>There's nothing in your program to tell the compiler that the argument
> method add_figure : 'a. (#figure as 'a) -> unit = fun f ->
> figures <- f#to_string :: figures
>
>Jacques Garrigue
thanks, i'd try (f:figure) but a need inherit.
and now is a second problem:
method add_figure : 'a. (#figure as 'a) -> string -> unit = fun f k ->
Hashtbl.add figures k f#to_string
work correctly, but
method add_figure : string -> 'a. (#figure as 'a) -> unit = fun k f ->
Hashtbl.add figures k f#to_string
return syntax error,
can i define method
add key figure = ...
???
--
Сегодня удачный день, чтобы завести почту на Яндексе (http://mail.yandex.ru)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-02-17 8:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-05 21:40 [Caml-list] Problem with classes or i need help inv2002
2003-02-05 16:31 ` [Caml-list] Ugly fonts in ocamlbrowser/editor Wai-Sun Chia
2003-02-06 6:35 ` Jacques Garrigue
2003-02-06 8:31 ` Wai-Sun Chia
2003-02-06 0:44 ` [Caml-list] Problem with classes or i need help Jacques Garrigue
2003-02-14 15:33 ` inv2002
2003-02-15 7:02 ` Jacques Garrigue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox