Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcuts for ./lib and ../lib #6338

Closed
p6rt opened this issue Jun 8, 2017 · 4 comments
Closed

Shortcuts for ./lib and ../lib #6338

p6rt opened this issue Jun 8, 2017 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jun 8, 2017

Migrated from rt.perl.org#131541 (status was 'rejected')

Searchable as RT131541$

@p6rt
Copy link
Author

p6rt commented Jun 8, 2017

From @Juerd

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;

:-)
--
Met vriendelijke groet, // Kind regards, // Korajn salutojn,

Juerd Waalboer <juerd@​tnx.nl>
TNX

@p6rt
Copy link
Author

p6rt commented Jun 9, 2017

From @zoffixznet

On Thu, 08 Jun 2017 16​:39​:40 -0700, juerd@​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&#8203;:
use lib ~$\*PROGRAM\.resolve\.parent\.sibling\('lib'\);

and​:

use lib :bindir\<lib>;
\# as a shortcut for&#8203;:
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
 

@p6rt
Copy link
Author

p6rt commented Jun 9, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jun 9, 2017

@zoffixznet - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Jun 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant