elvish/pkg/eval/builtin_fn_debug.d.elv
Qi Xiao 96752afa4d Make struct maps indistinguishable from maps to Elvish code.
Struct map is a mechanism to let Go code expose simple structs to Elvish code.
The difference between struct maps and maps is convenience for Go code; they
also have different performance characteristics, but since struct maps are
always quite small, the difference is not meaningful for Elvish's use cases.

As a result, there is no good reason that Elvish code needs to be aware of the
difference between struct maps and normal maps. Making them indistinguishable to
Elvish code simplifies the language.

This commit does the following:

- Change Equal, Hash, Kind and Repr to treat struct maps like maps.

- Change Assoc and Dissoc to "promote" struct maps to maps.

- Remove the custom Repr method of parse.Source.

- Update documentation to reflect this change.
2023-07-14 23:57:38 +01:00

42 lines
1.1 KiB
Plaintext

# Output a map describing the current source, which is the source file or
# interactive command that contains the call to `src`. The value contains the
# following fields:
#
# - `name`, a unique name of the current source. If the source originates from a
# file, it is the full path of the file.
#
# - `code`, the full body of the current source.
#
# - `is-file`, whether the source originates from a file.
#
# Examples:
#
# ```elvish-transcript
# ~> src
# ▶ [&code=src &is-file=$false &name='[tty 1]']
# ~> elvish show-src.elv
# ▶ [&code="src\n" &is-file=$true &name=/home/elf/show-src.elv]
# ~> echo src > .config/elvish/lib/show-src.elv
# ~> use show-src
# ▶ [&code="src\n" &is-file=$true &name=/home/elf/.config/elvish/lib/show-src.elv]
# ```
fn src { }
# Force the Go garbage collector to run.
#
# This is only useful for debug purposes.
#doc:show-unstable
fn -gc { }
# Print a stack trace.
#
# This is only useful for debug purposes.
#doc:show-unstable
fn -stack { }
# Direct internal debug logs to the named file.
#
# This is only useful for debug purposes.
#doc:show-unstable
fn -log {|filename| }