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

Additions to the Perl family of languages #4066

Merged
merged 28 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1732850
Mainly fixing problems with Perl heuristics
JJ Oct 31, 2015
9d57d6f
Adds new sample
JJ Nov 1, 2015
13d5ebd
Adds a couple of samples more, not represented before
JJ Nov 1, 2015
d3cf280
Moves installation intructions to CONTRIBUTING.md
JJ Nov 2, 2015
f437f0c
Correcting error. Great job, CI
JJ Nov 2, 2015
2d8cd85
Moving another file
JJ Nov 2, 2015
3466074
Merge branch 'master' of github.com:github/linguist
JJ Dec 13, 2015
f46e876
Adds samples and new checks for perl/perl6
JJ Dec 13, 2015
ff4f40a
Stupid mistake
JJ Dec 13, 2015
c1796bc
Changing regex for perl5 vs perl6
JJ Dec 13, 2015
f1491a6
Adds extensions to Perl
JJ Mar 13, 2018
22bd264
Eliminates Rexfile from Perl6
JJ Mar 13, 2018
0dca075
Followup to #2709
JJ Mar 13, 2018
a3aed35
Adds example for pod6
JJ Mar 13, 2018
2d85463
Eliminates .pod because it's its own language
JJ Mar 13, 2018
cc2e8a7
Removes bad directory
JJ Mar 13, 2018
4eaa4b3
Reverting changes that were already there
JJ Mar 13, 2018
5601865
Restored CONTRIBUTING.md from head
JJ Mar 13, 2018
6ce294d
Eliminates `.pod6`
JJ Mar 28, 2018
072e774
Merge branch 'master' of github.com:JJ/linguist
JJ Mar 28, 2018
648e8cb
Merge branch 'master' of github.com:github/linguist
JJ Mar 28, 2018
0bd8636
Removed by request, since we're no longer adding this extension
JJ Mar 28, 2018
a33ad3e
Solves conflict
JJ Apr 6, 2018
9dd0975
Sorting by alphabetical order filenames
JJ Apr 7, 2018
5f74ba4
Puts things in the required order
JJ Apr 9, 2018
52b5b91
Fixes another conflict
JJ Apr 9, 2018
2b46d79
Merge branch 'master' of github.com:github/linguist
JJ Apr 11, 2018
679bb4c
Moved from sample to test fixtures
JJ Apr 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3386,6 +3386,8 @@ Perl:
- ".psgi"
- ".t"
filenames:
- Makefile.PL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant, because it'll be matched against the *.pl file extension.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alhadis That extension is shared between Perl, Perl 6, and Prolog. Adding the Makefile.PL might improve detection for that particular case. Are we sure Makefile.PL is always Perl and not Perl 6 though?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stand corrected, then. 😉 @pchaigno knows more about the Bayesian classifier than I do.

I don't recall ever seeing a Perl 6 version of Makefile.PL... it's always ever been used by Perl 5 modules downloaded/installed from CPAN. I could be wrong though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure. Perl6 has pretty much normalized to .pl6 or .p6 now. It's not using this particular file, either. This is the repo for all modules https://github.com/moritz/perl6-all-modules/search?utf8=%E2%9C%93&q=%22Makefile.PL%22&type= and it's not there even once. Makefile.PL is kind of a Rakefile used for some CPAN distributions; Perl6 uses zef and META6.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pchaigno knows more about the Bayesian classifier than I do.

I don't know much about the classifier either, but in this particular case, there's a specific filename strategy before we reach the classifier.

PS: Not sure why I keep using "particular case" today...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping... Is there anything missing?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it looks fine to me. For the sake of quicker review, it might be better to omit .pod6 since #3366 is more appropriate for discussion its inclusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem there is that it might need a bit (or a lot) of work. If you want, you can close that one and I'll redo this one, and then that one...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminated .pod6. I can try and work on that one, although I can't add or modify that pull request...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry about #3366. :) I believe that PR needs formal approval from GitHub staff more than anything.

- Rexfile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In-the-wild usage is a little questionable... only ~155 results, although they appear to be well-distributed across users/repositories (which technically meets the criteria of "being used in hundreds of repositories"). I think it's okay, particularly since it's an uncommon filename unlikely to cause conflict. @pchaigno, thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer to @lildude 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem here is that Rexfile was actually in the Perl6 field (my fault: https://github.com/github/linguist/pull/2005/files). It should better be here, Rexfile is in no way Perl6 code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine. It slipped under the radar before when it was initially added so no point removing it now.

- ack
- cpanfile
interpreters:
Expand All @@ -3409,8 +3411,6 @@ Perl 6:
- ".pm"
- ".pm6"
- ".t"
filenames:
- Rexfile
interpreters:
- perl6
aliases:
Expand Down
100 changes: 100 additions & 0 deletions samples/Perl/Any.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
use strict; #-*-cperl-*-
use warnings;

use lib qw( ../../../../lib );

=encoding utf8

=head1 NAME

Algorithm::Evolutionary::Fitness::Any - Façade for any function so that it can be used as fitness

=head1 SYNOPSIS

use Algorithm::Evolutionary::Utils qw( string_decode )

sub squares {
my $chrom = shift;
my @values = string_decode( $chrom, 10, -1, 1 );
return $values[0] * $values[1];
}

my $any_eval = new Algorithm::Evolutionary::Fitness::Any \&squares;


=head1 DESCRIPTION

Turns any subroutine or closure into a fitness function. Useful mainly
if you want results cached; it's not really needed otherwise.

=head1 METHODS

=cut

package Algorithm::Evolutionary::Fitness::Any;

use Carp;

use base 'Algorithm::Evolutionary::Fitness::Base';

our $VERSION = '3.2';

=head2 new( $function )

Assigns default variables

=cut

sub new {
my $class = shift;
my $self = { _function => shift || croak "No functiona rray" };
bless $self, $class;
$self->initialize();
return $self;
}

=head2 apply( $individual )

Applies the instantiated problem to a chromosome. It is actually a
wrapper around C<_apply>.

=cut

sub apply {
my $self = shift;
my $individual = shift || croak "Nobody here!!!";
$self->{'_counter'}++;
return $self->_apply( $individual );
}

=head2 _apply( $individual )

This is the one that really does the stuff. It applies the defined
function to each individual. Itis cached for efficiency.

=cut

sub _apply {
my $self = shift;
my $individual = shift || croak "Nobody here!";
my $chrom = $individual->Chrom();
my $cache = $self->{'_cache'};
if ( $cache->{$chrom} ) {
return $cache->{$chrom};
}
my $result = $self->{'_function'}->($chrom);
if ( (scalar $chrom ) eq $chrom ) {
$cache->{$chrom} = $result;
}
return $result;
}


=head1 Copyright

This file is released under the GPL. See the LICENSE file included in this distribution,
or go to http://www.fsf.org/licenses/gpl.txt

=cut

"What???";
20 changes: 20 additions & 0 deletions samples/Perl/filenames/Makefile.PL
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;

WriteMakefile(
NAME => 'Algorithm::Evolutionary::Simple',
AUTHOR => 'JJ Merelo <[email protected]>',
VERSION_FROM => 'lib/Algorithm/Evolutionary/Simple.pm',
ABSTRACT_FROM => 'lib/Algorithm/Evolutionary/Simple.pm',
LICENSE => 'gpl',
EXE_FILES => [ 'script/simple-EA.pl', 'script/maxones.pl'],
PREREQ_PM => {
'Test::More' => 0,
'Carp' => 0,
'Exporter' => 0,
'Sort::Key::Top' => 0
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Algorithm-Evolutionary-Simple-*' },
);
9 changes: 9 additions & 0 deletions samples/Perl/filenames/Rexfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use Rex -feature => ['1.0'];

user "eleccionesugr";
group eleccionesugr => "elecciones-ugr.cloudapp.net";

desc "Install perlbrew";
task "perlbrew", group => "eleccionesugr", sub {
};

9 changes: 9 additions & 0 deletions test/fixtures/Perl 6/chromosome.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Chromosome {
has Seq $.chromosome is rw;
has $.fitness is rw;

}

my $len = 32;
my $this-chromosome = Chromosome.new( chromosome => map( { rand >= 0.5 ?? True !! False }, 1..$len ) );
say $this-chromosome.chromosome();