mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-12 17:27:50 +08:00
96752afa4d
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.
42 lines
1.1 KiB
Plaintext
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| }
|