Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
KLELSTDLIB(1)			     libklel			   KLELSTDLIB(1)

INTRODUCTION
     This manual page documents the standard library of variables and functions
     available for use in KL-EL expressions.  For documentation on how to embed
     the KL-EL compiler and interpreter in an application, see klelapi(3).  For
     a tutorial on how to use the library, see kleltut(3).  For documentation on
     the expression language itself, see klellang(3).

FUNCTIONS
     The following sub-sections describe the various arithmetic, string, and
     time functions exported by the standard library for general use in KL-EL
     expressions.

   ARITHMETIC FUNCTIONS
     int abs(int x);
	 Returns the absolute value of x.

     int entier(real x);
	 Converts x to an integer, rounding towards negative infinity.

     real real(int x);
	 Converts x to a real number.

     int max(int x, int y);
	 Returns the larger of x and y.

     int min(int x, int y);
	 Returns the smaller of x and y.

     bool odd(int x);
	 Returns true if x is odd.

   STRING FUNCTIONS
     int cksum(string x);
	 Computes a simple 16-bit checksum of x using the original BSD checksum
	 algorithm.

     string chr(int x);
	 Returns a string containing a single character whose character code is
	 equal to x.

     int ord(string x);
	 Returns the character code of the first character of x.

     int strlen(string x);
	 Returns the length in bytes of x.

     string string_of_bool(bool x);
	 Returns the string "true" if x is true; otherwise, it returns "false".

     string string_of_real(real x);
	 Returns the string representation of x in decimal notation.

     string string_of_int(int x);
	 Returns the string representation of x in decimal notation.

     string dec_of_int(int x);
	 An alias for string_of_int.

     string hex_of_int(int x);
	 Returns the string representation of x in hexadecimal notation.

     string oct_of_int(int x);
	 Returns the string representation of x in octal notation.

   TIME FUNCTIONS
     int now();
	 Returns the number of seconds since the epoch.

     string ctime();
	 Returns the current time as reported by the ctime(3) function.

   ERROR FUNCTIONS
     int abort_bool(string message);
	 Aborts execution (produces a runtime error, causing KlelExecute to re-
	 turn NULL) with the given message pushed onto the error stack.  Does
	 not return, but purports to return a boolean, allowing it to be used in
	 boolean expressions.

     int abort_int(string message);
	 As for abort_bool, but purports to return an integer.

     int abort_real(string message);
	 As for abort_bool, but purports to return an real number.

     int abort_string(string message);
	 As for abort_bool, but purports to return an string.

VARIABLES
     The following variables are defined in the standard library:

			   ======= DEFINITION =======
				   t  d
				   y  e
				   p  s
				   e  c
				      r
				      i
				      p
				      t
				      i
				      o
				      n
	======	 VARIABLE  ==========================
	true			   B  Boolean true
	false			   B  Boolean false
	pi			   R  3.1415926535897932384 (approximation)
	e			   R  2.7182818284590452354 (approximation)

SEE ALSO
     klel-expr(1), klelapi(3), klellang(3), kleltut(3)

1.1.0				   2026-08-27			   KLELSTDLIB(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=klelstdlib&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help