Skip to content

Instantly share code, notes, and snippets.

@hoelzro

hoelzro/notes.md Secret

Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoelzro/71b65aec6cdc2574da60 to your computer and use it in GitHub Desktop.
Save hoelzro/71b65aec6cdc2574da60 to your computer and use it in GitHub Desktop.
Perl 6 Language Ideas

Documenting non-declarations

While implementing S26, it occurred to me that there may be cause to document certain things that aren't declarations. For example, augment:

#| This should probably add to, or perhaps replace MyClass.WHY?
augment class MyClass {
}

Or perhaps a return value?

sub multiply(
  #| The multiplicand
  Int $a,
  #| The multiplier
  Int $b
  #| The product
  --> Int
) { $a * $b }

Consecutive leading/trailing comments

If I have multiple consecutive #| or #= comments on a single declaration, they should be merged into one, right? For example:

#| One
#| Two
sub decl() {}
#= Three
#= Four

is &decl.WHY.leading, 'One Two';
is &decl.WHY.trailing, 'Three Four';

Advanced forms of open

In Perl 5, one can re-open (or dup) a file handle like so:

open my $copy, '>&', \*STDOUT;

This is normally done to fiddle with standard I/O handles before handing off control to a child process or something. I was thinking that this would be a good idea to add to Perl 6, accomplished by providing an existing IO::Handle to open:

my ( $read, $write ) = create-pipe;

if $child {
  $read.close;
  $*OUT = open($write);
  # exec child
}

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment