This page has been written by Hubert Tonneau, then enhanced by William Merriam.
In pliant, you only specify what kind of operations your function wants to do on the argument. There are three access modes for an argument:
Now for the result. You have to choose between:
and also:
The calling conventions of Pliant are much more efficient than in C++. Let's take an example:
function three_times s -> sss arg Str s sss sss := s+s+s
Str three_times(const Str &s) { return s+s+s ; }
Here are a few examples:
function factorial x -> f arg Int x f if x=0 f := 1 else f := x * (factorial x-1)
Second example, first version:
function first_char s -> c arg Str s ; arg_C Char c c :> s 0
Second example, second version:
function first_char s -> c arg Str s ; arg Char c c := s 0
var Str test := "abc" var Char c1 := first_char test console c1 eol
But now, if we write:
var Str test := "abc" first_char test := character 65 console test eol