I personally found the old resolve builtin (still documented, but gone in master) extremely useful to quickly see where a command is coming from as per the command resolution rules.
Before:
[~]─> resolve ls
â–¶ <closure 0xc420462a20> # my ls alias
Now:
[~]─> put $builtin:ls
Compilation error: variable $builtin:ls not found
[tty], line 1: put $builtin:ls
[~]─> put $ls~
â–¶ <closure 0xc420462a20>
[~]─> search-external ls
â–¶ /Users/taazadi1/.nix-profile/bin/ls
Of course this is a contrived example, and it could easily be automated in a function, but since Elvish has to resolve the command anyway, I would vote for exposing this functionality again.
To be accurate, the new resolve also should resolve special commands like use. For that reason, it cannot write a callable value. It will write a string instead.
Returning a string is obviously closest to what other shells do with commands like type ls. I can't think of any reason why it should return a callable. However, it might be better to return something more structured than a simple string. For example, from Fish shell:
$ type and 5.3 s
and is a builtin
$ type ls 4 ms
ls is a function with definition
# Defined in /usr/local/share/fish/functions/ls.fish @ line 34
function ls --description 'List contents of directory'
command ls -G $argv
end
$ type od 36 ms
od is /usr/bin/od
That is okay when a human is interpreting the output but a structured return value would make the command much more useful to other functions. And likely without any loss of usefulness to an interactive user of the command.
@krader1961 That is interesting, but I have opted to not implement those. The reason is different for functions and externals:
Functions already have their own introspection methods (#560, which is already fixed!). There is one limitation (#617) which I wish to fix though.
In Elvish terminology, "resolve" means strictly static resolution. External commands undergo two processes: static resolution in the compilation phase when they merely gets tagged to be external, and dynamic searching in the evaluation phase when their path is found. The resolve commands only emualtes static resolution and does not do the searching: the search-external command is exactly for that.
Most helpful comment
To be accurate, the new
resolvealso should resolve special commands likeuse. For that reason, it cannot write a callable value. It will write a string instead.