* Setting function in a class
@ 2010-07-19 7:30 Keyan Zahedi
2010-07-19 7:37 ` [Caml-list] " Stéphane Glondu
0 siblings, 1 reply; 3+ messages in thread
From: Keyan Zahedi @ 2010-07-19 7:30 UTC (permalink / raw)
To: caml-list
hi,
i have the following question: i would like to create a class with functions that can be set later. here is an example:
class myclass =
object
val mutable _myfunc = (* a function of type string -> bool)
method set_myfunc f = _myfunc <- f
method my_func f = _myfunc f
;;
of course the code above does not work.
can anyone tell me how to do this?
regards,
keyan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Setting function in a class
2010-07-19 7:30 Setting function in a class Keyan Zahedi
@ 2010-07-19 7:37 ` Stéphane Glondu
2010-07-19 8:01 ` Keyan Zahedi
0 siblings, 1 reply; 3+ messages in thread
From: Stéphane Glondu @ 2010-07-19 7:37 UTC (permalink / raw)
To: Keyan Zahedi; +Cc: caml-list
Le 19/07/2010 09:30, Keyan Zahedi a écrit :
> class myclass =
> object
> val mutable _myfunc = (* a function of type string -> bool)
> method set_myfunc f = _myfunc <- f
> method my_func f = _myfunc f
> ;;
I am not sure of what blocks you. Just making your snippet syntactically
correct works:
class myclass =
object
val mutable _myfunc = fun (s:string) -> true
method set_myfunc f = _myfunc <- f
method my_func f = _myfunc f
end
;;
Cheers,
--
Stéphane
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Setting function in a class
2010-07-19 7:37 ` [Caml-list] " Stéphane Glondu
@ 2010-07-19 8:01 ` Keyan Zahedi
0 siblings, 0 replies; 3+ messages in thread
From: Keyan Zahedi @ 2010-07-19 8:01 UTC (permalink / raw)
To: Stéphane Glondu; +Cc: caml-list
hi,
this is indeed my code. being sure, that my code is correct, i was able to locate the problem somewhere else :)
thanks!
keyan
On 19 Jul 2010, at 09:37, Stéphane Glondu wrote:
> Le 19/07/2010 09:30, Keyan Zahedi a écrit :
>> class myclass =
>> object
>> val mutable _myfunc = (* a function of type string -> bool)
>> method set_myfunc f = _myfunc <- f
>> method my_func f = _myfunc f
>> ;;
>
> I am not sure of what blocks you. Just making your snippet syntactically
> correct works:
>
> class myclass =
> object
> val mutable _myfunc = fun (s:string) -> true
> method set_myfunc f = _myfunc <- f
> method my_func f = _myfunc f
> end
> ;;
>
>
> Cheers,
>
> --
> Stéphane
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-19 8:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-19 7:30 Setting function in a class Keyan Zahedi
2010-07-19 7:37 ` [Caml-list] " Stéphane Glondu
2010-07-19 8:01 ` Keyan Zahedi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox