Documentation for Ice 3.4. The latest release is Ice 3.7. Refer to the space directory for other releases.

A Slice constant maps to a PHP constant. Consider the following definitions:

Slice
module M {
    const bool      AppendByDefault = true;
    const byte      LowerNibble = 0x0f;
    const string    Advice = "Don't Panic!";
    const short     TheAnswer = 42;
    const double    PI = 3.1416;

    enum Fruit { Apple, Pear, Orange };
    const Fruit     FavoriteFruit = Pear;
};

The mapping for these constants is shown below:

PHP
define('M_AppendByDefault', true);
define('M_LowerNibble', 15);
define('M_Advice', "Don't Panic!");
define('M_TheAnswer', 42);
define('M_PI', 3.1416);
define('M_FavoriteFruit', M_Fruit::Pear);

An application refers to a constant using its flattened name:

PHP
$ans = M_TheAnswer;

Using the namespace mapping, Slice constants are mapped to PHP constants in the enclosing namespace:

PHP
$ans = \M\TheAnswer;
See Also
  • No labels