On Thu, 08 Jun 2017 16:39:40 -0700, ju...@tnx.nl wrote: > Because putting bundled libraries in ./lib or ../lib relative to the > executable is so common, I'd like to request a feature for shortcuts for > these. > > I'm thinking of: > > use lib :parentdir<lib>; > # as a shortcut for: > use lib ~$*PROGRAM.resolve.parent.sibling('lib'); > > and: > > use lib :bindir<lib>; > # as a shortcut for: > use lib ~$*PROGRAM.resolve.sibling('lib'); > > With defaults to 'lib' so that they can also be written as: > > use lib :parentdir; > use lib :bindir; > > Or maybe even just something that simply includes both ./lib and ../lib: > > use lib :dwim; > > :-)
Thank you for the suggestion, however, I'm going to reject the ticket. The proposed syntax gives entirely new meaning to syntax for export tags we already use with modules and the proposed behaviour is too poorly defined. For example $*PROGRAM is `-e` in perl6 -e '' and `iteractive` when in REPL, so it doesn't generalize well. This is the perfect feature to make a module out of, since you're already `use`ing something. The syntax would just have an extra hyphen in it: use lib-parent 'lib'; use lib-bindir 'lib'; use lib-dwim; I would suggest you go with that approach. $ tree . ├── ./bar │ └── ./bar/Foo.pm6 └── ./lib-bin.pm6 1 directory, 2 files $ cat bar/Foo.pm6 unit module Foo; sub foo is export { say "foobar" }; $ cat lib-bin.pm6 no precompilation; sub EXPORT ($lib) { .use-repository: .repository-for-spec: $*PROGRAM.resolve.sibling: $lib given CompUnit::RepositoryRegistry; {} } $ perl6 -I. -e 'use lib-bin "bar"; use Foo; foo' foobar