Robert Roessler wrote:
...
(* function def *)
let word_from_position editor pos =
    if pos < 0 || pos >= editor#get_length then ""
    else
        let a = editor#word_start_position pos true in
        let b = editor#word_end_position pos true in
        editor#get_text_range {cpMin=a; cpMax=b}

(* called as *)
word_from_position editor (editor#position_from_point_close x y)

All of the "editor#..." calls correspond to existing builtin functions in Scintilla; also, the "{cpMin=a; cpMax=b}" dynamically builds a struct of the type expected by get_text_range.

Finally, note that even in the absence of declarations, this *is* strongly typed (but inferred): since pos is used with integer comparisons, it must be an int; editor is required to be an object which has *at least* get_length, word_start_position, word_end_position, get_text_range, and position_from_point_close as methods... there is exactly one struct type that has cpMin and cpMax etc.

Sigh - I tried to oversimplify a trick subject and ended up with something that is incorrect: while *arithmetic* operators like + and - are typed to work with ints, the *comparison* operators shown (< and >=) are actually not type-specific... == and != are the only [int-] typed comparison operators.

Not to mislead anyone. :)

Robert Roessler
[EMAIL PROTECTED]
http://www.rftp.com
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to