Download CDuce Programming Language User`s manual

Transcript
3.14 System
Running external commands
The predefined function system executes an external command (passed to
/bin/sh) and returns its standard output and standard error channels and its exit
code. The type for system is:
Latin1 -> { stdout = Latin1; stderr = Latin1;
status = (`exited,Int) | (`stopped,Int) | (`signaled,Int) |}
Terminating the program
The predefined function exit: 0--255 -> Empty terminates the current process.
The argument is the exit code.
Accessing the environment
The built-in function getenv: Latin1 -> Latin1 queries the system
environment for an environment variable. If the argument does not refer to an
existing variable, the function raises the exception `Not_found.
Command line arguments
The built-in function argv: [] -> [ String* ] returns the sequence of
command line arguments given to the current program.
3.15 Namespaces
It is possible in expression position to define a local prefix-namespace binding or to
set a local default namespace.
namespace p = "..." in e
namespace "..." in e
See for more details.
3.16 Imperative features
The construction ref T e is used to build a reference initialized with the result of the
expression e; later, the reference can receive any value of type T. The reference is
actually a value of type { get = [] -> T ; set = T -> [] }.
28