List Info

Thread: "ocaml_beginners"::[] Can't verify object data ?




"ocaml_beginners"::[] Can't verify object data ?
country flaguser name
United States
2007-09-05 04:38:41

Hi,

I am working with an object :

class state_view =
object
val mutable expanded : bool = true;
val mutable links_opt : (string * int) list option = None;
val mutable locals_opt : Ext.t option = None;
val mutable links_options : Context.links_option list = [];
val mutable links_sort_fun : links_sort_fun = sort_by_count;

method expanded = expanded
method links_opt = links_opt
method locals_opt = locals_opt
method links_options = links_options
method links_sort_fun = links_sort_fun

method set_expanded b = expanded <- b
method set_links_opt l = links_opt <- l
method set_locals_opt ext = locals_opt <- ext
method set_links_options options = links_options <- options
method set_links_sort_fun f = links_sort_fun <- f

method copy = {< links_opt = None; locals_opt = None >}
end

the "links_sort_fun" is a function. I can put "sort_by_count&quot; or
";sort_by_feature" into it with the function "set_links_sort_fun
(sort_by_feature/sort)&quot;

I need to know what is in this variable. So I verify but if I write :

if (links_sort_fun = sort_by_feature) then ....

It's compiled but I got an execution error.

If I write :

match links_sort_fun with
sort_by_count -> ....
| sort_by_feature ->....

I ALWAYS match sort_by_count even if I would be supposed to have
&quot;sort_by_feature&quot;. And I got a warning telling me that the case line X
(X is the line of | sort_by_feature -> ...) is unused :s
Furthermore If I write

match links_sort_fun with
blbibljljlmqdsjfmqjf -> ...
| ....

That's the same thing, I always match blbibljljlmqdsjfmqjf ...

So how can I know what is in this variable ?

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] Re: Can't verify object data ?
country flaguser name
United States
2007-09-05 04:43:37

OK I found out the way of doing this

if links_sort_fun==sort_by_count ...

It's works. But why my match did not work too?

--- In ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com, "bobshibby36&quot;
<bobshibby36...> wrote:
&gt;
> Hi,
>
> I am working with an object :
>
> class state_view =
> object
&gt; val mutable expanded : bool = true;
&gt; val mutable links_opt : (string * int) list option = None;
&gt; val mutable locals_opt : Ext.t option = None;
&gt; val mutable links_options : Context.links_option list = [];
> val mutable links_sort_fun : links_sort_fun = sort_by_count;
>
> method expanded = expanded
> method links_opt = links_opt
> method locals_opt = locals_opt
> method links_options = links_options
> method links_sort_fun = links_sort_fun
>
> method set_expanded b = expanded <- b
> method set_links_opt l = links_opt <- l
> method set_locals_opt ext = locals_opt <- ext
> method set_links_options options = links_options <- options
> method set_links_sort_fun f = links_sort_fun <- f
>
> method copy = {< links_opt = None; locals_opt = None >}
&gt; end
>
> the "links_sort_fun" is a function. I can put "sort_by_count&quot; or
> "sort_by_feature" into it with the function "set_links_sort_fun
> (sort_by_feature/sort)"
>
> I need to know what is in this variable. So I verify but if I write :
>
> if (links_sort_fun = sort_by_feature) then ....
>;
> It's compiled but I got an execution error.
&gt;
> If I write :
>
> match links_sort_fun with
>; sort_by_count -> ....
>; | sort_by_feature ->....
>
> I ALWAYS match sort_by_count even if I would be supposed to have
>; "sort_by_feature". And I got a warning telling me that the case line X
> (X is the line of | sort_by_feature -> ...) is unused :s
> Furthermore If I write
>
> match links_sort_fun with
> blbibljljlmqdsjfmqjf -> ...
> | ....
>;
> That's the same thing, I always match blbibljljlmqdsjfmqjf ...
>
> So how can I know what is in this variable ?
>

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )