2.2. The use directive

The open directive opens a whole module for internal use. Sometimes that is too coarse grained. The use directive allows you to import individual names into the current scope to reference with an unqualified name. The entity refered to can be a non-function, or a set of functions, and it can also be renamed in the use directive. The renaming feature can also be used on names in the current scope.

Note that you can't sensibly use a name from an opened module, nor open a module using a used name (even as a prefix).

Start C++ section to tut/examples/tut206a.flx[1 /1 ]
     1: header "#include <iostream>";
     2: module X {
     3:   type int = "int";
     4:   proc print: int = "std::cout << $1;";
     5:   proc endl: 1 = "std::cout << std::endl;";
     6: }
     7: 
     8: use X::int;
     9: use eol = X::endl;
    10: 
    11: val x:int = 1;
    12: use y = x;
    13: X::print y; eol;
    14: 
End C++ section to tut/examples/tut206a.flx[1]
You can see the two forms of the use directive:
  use qualified_name;
  use new_name = old_qualified_name;
The first form requires a proper qualified name and is equivalent to the second form, where the new_name is the last component of the qualified_name.