Ralph Douglass wrote:
> With labeled functions, I usually do something like ~snoo:_, but it does
> not work in this exampled with methods:
> ---
> class foo = object
> method bar ~(snoo : string):_ = ()
> end;;
In this case the ':_' denotes a type annotation, using the "any-type"
expression '_'. You're declaring the return type of the method, as
you'll see if you change the annotation to something incompatible with
unit, such as
class foo = object
method bar ~(snoo : string):int = ()
end
> On a whim, I did the following, which surprisingly worked:
>
> class foo = object
> method bar ~(_snoo : string) = ()
> end;;
This works because the "unused variables" warning is disabled for
variables which start with an underscore. It's a useful feature for
normal bindings but I don't think you should use it for labels, since it
changes the interface.
> Is there a solution to this?
I think the following is what you want:
class foo = object
method bar ~snoo:(_:string) = ()
end
Jeremy.