Skip to content

Completion in XCAS, OCaml and C ​

After SQL, JavaScript and R, the Tab key now completes names in XCAS, OCaml and C, in the console, the notebook and the basthon command. All of Basthon's languages now have completion.

In XCAS, completion knows Giac's 1,700 or so commands, with their French synonyms: fact offers factor, factorial, factoriser, facteurs_premiers… Add to that the keywords of programs (if, for, while, function, and their French equivalents) and the variables and functions you defined.

area(r) := pi*r^2;
area(3)

Try it in the XCAS console

In OCaml, completion asks the toplevel itself: it offers the values, constructors and modules known, including those you just defined or opened with open, and the members of a module: List.ma offers map, map2 and mapi. It also works for the libraries loaded with #require (Z. after #require "zarith"), for their names (#require "za gives zarith) and for the modules added to the project. This work is a contribution by Pierre Le-Scornet: thanks to him!

ocaml
let rec sum = function
  | [] -> 0
  | x :: rest -> x + sum rest;;

(* try Tab after "su" or "List.fo" *)
sum (List.init 10 Fun.id);;

Try it in the OCaml console

In C, completion offers the headers after #include <, then what the included headers declare: strl gives strlen( after #include <string.h>, uint8 gives uint8_t after #include <stdint.h>. The keywords and the names of the program (variables, functions) are completed too.

The page of each language details what is completed.