Singular Manual: reference declarations

  | ### 4.29.1 reference declarations Syntax: reference name `=` identifier `;` Purpose: defines a `reference` object. Default: `None` Example:
      system("reference"); system("shared");
        reference empty;
        empty;
      ==> <unassigned reference or shared memory>

        string str = "Hello World!";
        reference ref = str;
        ref;
      ==> Hello World!
      ==>
        ref = 17;    // cannot change type of 'i'
      ==>    ? `string`(str) = `int` is not supported
      ==>    ? expected `string` = `string`
      ==>    ? error occurred in or before ./examples/reference_declarations.sing l\
         ine 8: `  ref = 17;    // cannot change type of 'i'`
        list ll= list(4, 5, 6);
        reference lref = ll[2];
        lref;
      ==> 5
      ==>
        lref = str;  // change list element
        ll;
      ==> [1]:
      ==>    4
      ==> [2]:
      ==>    Hello World!
      ==> [3]:
      ==>    6

User manual for Singular version 4.4.1, 2025, generated by texi2html.