### 5.1.102 nameof

`Syntax:`
  `nameof (` expression `)`
`Type:`
  string
`Purpose:`
  returns the name of an expression as string.
`Example:`

        int i=9;
        string s=nameof(i);
        s;
      ==> i
        nameof(s);
      ==> s
        nameof(i+1); //returns the empty string:
      ==>
        nameof(basering);
      ==> basering
        basering;
      ==>    ? `basering` is undefined
      ==>    ? error occurred in or before ./examples/nameof.sing line 7: `  baseri\
         ng;`
        ring r;
        nameof(basering);
      ==> r

See names; reservedName; typeof.

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