[perl #131541] Shortcuts for ./lib and ../lib
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; > # as a shortcut for: > use lib ~$*PROGRAM.resolve.parent.sibling('lib'); > > and: > > use lib :bindir; > # 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
[perl #131541] Shortcuts for ./lib and ../lib
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; > # as a shortcut for: > use lib ~$*PROGRAM.resolve.parent.sibling('lib'); > > and: > > use lib :bindir; > # 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
[perl #131541] Shortcuts for ./lib and ../lib
# New Ticket Created by Juerd Waalboer # Please include the string: [perl #131541] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=131541 > 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; # as a shortcut for: use lib ~$*PROGRAM.resolve.parent.sibling('lib'); and: use lib :bindir; # 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; :-) -- Met vriendelijke groet, // Kind regards, // Korajn salutojn, Juerd WaalboerTNX