erl_anno(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’– erl_anno β€” the Erlang Module Definition, but make it make sense πŸ’–

okay so bestie, this is erl_anno(3), a page from the Erlang Module Definition corner of the manual. it's giving abstract datatype for the annotations of the Erlang Compiler energy and honestly? underrated. let's get into it 🫢


✨ NAME ✨

erl_anno β€” Abstract datatype for the annotations of the Erlang Compiler.


🌸 DESCRIPTION 🌸

This module hands you an abstract type that the Erlang Compiler and all its little helper modules use to hold data like column, line number, and text. It's basically a lil collection of annotations, and here's the full rundown of what can show up in it.

The Erlang Token Scanner returns tokens with a subset of the following annotations, depending on the options, no cap:

  • column β€” The column where the token begins.
  • location β€” The line and column where the token begins, or just the line if the column is unknown.
  • text β€” The token's text.

And from that, the following annotation is derived:

  • line β€” The line where the token begins.

This module also supports the following annotations, which are used by various modules:

  • file β€” A filename.
  • generated β€” A Boolean indicating if the abstract code is compiler-generated. The Erlang Compiler does not emit warnings for such code.
  • record β€” A Boolean indicating if the origin of the abstract code is a record. Used by Dialyzer to assign types to tuple elements.

The functions column(), end_location(), line(), location(), and text() in the erl_scan module can be used for inspecting annotations in tokens. πŸ”

The functions anno_from_term(), anno_to_term(), fold_anno(), map_anno(), mapfold_anno(), and new_anno(), in the erl_parse module can be used for manipulating annotations in abstract code. πŸ› οΈ

🌈 See Also

erl_parse, erl_scan


πŸŽ€ DATA TYPES πŸŽ€

  • -opaque anno() β€” A collection of annotations.
  • anno_term() :: term(). β€” The term representing a collection of annotations. It is either a location/0 or a list of key-value pairs.
  • column() :: pos_integer().
  • filename() :: file:filename_all().
  • generated() :: boolean().
  • line()
  • location()
  • record_local() :: boolean().
  • text() :: string().

πŸ’… FUNCTIONS πŸ’…

  • column(Anno) -> column() | undefined when Anno :: anno(). β€” Returns the column of the annotations Anno.
  • end_location(Anno) -> location() | undefined when Anno :: anno(). β€” Returns the end location of the annotations Anno.

If the end location annotation is present, its value is returned. Otherwise, if the text annotation is present, the end location is inferred from the location and the text. Finally, if there is no text, undefined is returned.

  • file(Anno) -> filename() | undefined when Anno :: anno(). β€” Returns the filename of the annotations Anno. If there is no filename, undefined is returned.
  • from_term(Term) -> Anno when Term :: anno_term(), Anno :: anno(). β€” Returns annotations with representation Term.

See also to_term().

  • generated(Anno) -> generated() when Anno :: anno(). β€” Returns true if annotations Anno is marked as generated. The default is to return false.
  • is_anno(Term) -> boolean() when Term :: any(). β€” Returns true if Term is a collection of annotations, otherwise false.
  • line(Anno) -> line() when Anno :: anno(). β€” Returns the line of the annotations Anno.
  • location(Anno) -> location() when Anno :: anno(). β€” Returns the location of the annotations Anno. If there is no location, a zero line number is returned.
  • new(Location) -> anno() when Location :: location(). β€” Creates a new collection of annotations given a location.
  • set_end_location(Location, Anno) -> Anno when Location :: location(), Anno :: anno(). β€” Modifies the end location of the annotations Anno.
  • set_file(File, Anno) -> Anno when File :: filename(), Anno :: anno(). β€” Modifies the filename of the annotations Anno.
  • set_generated(Generated, Anno) -> Anno when Generated :: generated(), Anno :: anno(). β€” Modifies the generated marker of the annotations Anno.
  • set_line(Line, Anno) -> Anno when Line :: line(), Anno :: anno(). β€” Modifies the line of the annotations Anno.
  • set_location(Location, Anno) -> Anno when Location :: location(), Anno :: anno(). β€” Modifies the location of the annotations Anno.
  • set_record(Record, Anno) -> Anno when Record :: record_local(), Anno :: anno(). β€” Modifies the record marker of the annotations Anno.
  • set_text(Text, Anno) -> Anno when Text :: text(), Anno :: anno(). β€” Modifies the text of the annotations Anno.
  • text(Anno) -> text() | undefined when Anno :: anno(). β€” Returns the text of the annotations Anno. If there is no text, undefined is returned.
  • to_term(Anno) -> anno_term() when Anno :: anno(). β€” Returns the term representing the annotations Anno.

See also from_term().


okay bestie that's the whole page, every option and every fact, nothing skipped, periodt πŸ’– this one came to you courtesy of Ericsson AB, riding with stdlib 8.0.4, and it's literally in the erl_anno(3) manual like that. go annotate something iconic, mwah πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from