Function: intern

intern is a function defined in lread.c.

Signature

(intern STRING &optional OBARRAY)

Documentation

Return the canonical symbol whose name is STRING.

If there is none, one is created by this function and returned. A second optional argument specifies the obarray to use; it defaults to the value of obarray.

Other relevant functions are documented in the symbol group.

View in manual

Probably introduced at or before Emacs version 19.20.

Shortdoc

;; symbol
(intern "abc")
    => abc

Source Code

// Defined in /usr/src/emacs/src/lread.c
{
  Lisp_Object tem;

  obarray = check_obarray (NILP (obarray) ? Vobarray : obarray);
  CHECK_STRING (string);


  char* longhand = NULL;
  ptrdiff_t longhand_chars = 0;
  ptrdiff_t longhand_bytes = 0;
  tem = oblookup_considering_shorthand (obarray, SSDATA (string),
					SCHARS (string), SBYTES (string),
					&longhand, &longhand_chars,
					&longhand_bytes);

  if (!SYMBOLP (tem))
    {
      if (longhand)
	{
	  tem = intern_driver (make_specified_string (longhand, longhand_chars,
						      longhand_bytes, true),
			       obarray, tem);
	  xfree (longhand);
	}
      else
	tem = intern_driver (NILP (Vpurify_flag) ? string : Fpurecopy (string),
			     obarray, tem);
    }
  return tem;
}