Re: Binding for gtkSourceView-2.0
Edgar Friendly <[email protected]>
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
Mike Spivey wrote: > (1) Is there a fixed rule for what methods take () as a final parameter? > Methods with side effects and no arguments, yes; but what about methods > like > > method guess_language : > ?filename:string -> ?content_type:string > -> unit -> source_language (* or raise Not_found *) > > that have no side-effects and only optional arguments? > Yes on methods with only optional parameters. Unless there's a non-optional parameter, uses without arguments could be partial. General rule: use () as final parameter when necessary - when you need to be able to force non-partial application. > (2) On the same example: if a C method with type t may return NULL, then > we have multiple possibilities in OCaml: > > (i) return "t option" > (ii) return "t", but raise Not_found if the result is NULL > (iii) if t = string, then return the empty string for NULL > > A similar question applies to arguments that may be NULL. Is there a > rule that I should follow? > Depends on whether returning NULL is really exceptional, but probably not (iii), unless the empty string really is meant by a NULL response. E.