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

Tune Perl/Raku heuristics #6264

Merged
merged 6 commits into from
Feb 17, 2023
Merged

Conversation

mauke
Copy link
Contributor

@mauke mauke commented Jan 25, 2023

Closes #6263.

Description

  • Relax Perl pattern: use 5; and use v5; are acceptable (no . required).

  • Treat use constant and use overload as Perl; Raku has different mechanisms for constants and operator overloading.

  • Treat assignments to @EXPORT as Perl (Raku has a different symbol export mechanism):

    our @EXPORT = (...);
    @EXPORT = (...);
    *EXPORT = [...];
  • Treat package declarations as Perl, not Raku:

    package Foo::Bar;
    package Foo::Bar v1.2.3;
    package Foo::Bar 1.05;
    package Foo::Bar { ... }
  • As a last resort, recognize the use of -> for dereferencing and method calls as indicative of Perl (Raku uses . for methods and has no references):

    Some::Class->class_method
    $some_variable->method
    $Some::Class::variable->method
    $array_reference->[0]
    $hash_reference->{key}
    $code_reference->(@arguments)

Checklist

  • I am fixing a misclassified language
    • I have included a new sample for the misclassified language:
      • Sample source(s): N/A (original)
      • Sample license(s): MIT
    • I have included a change to the heuristics to distinguish my language from others using the same extension.

- Relax Perl pattern: 'use 5;' and 'use v5;' are acceptable (no '.'
  required).

- Treat 'use constant' and 'use overload' as Perl; Raku has different
  mechanisms for constants and operator overloading.

- Treat assignments to @export as Perl (Raku has a different symbol
  export mechanism):

      our @export = (...)
      @export = (...)
      *EXPORT = [...]

- Treat package declarations as Perl, not Raku:

      package Foo::Bar;
      package Foo::Bar v1.2.3;
      package Foo::Bar 1.05;
      package Foo::Bar { ... }

- As a last resort, recognize the use of '->' for dereferencing and
  method calls as indicative of Perl (Raku uses '.' for methods and has
  no references):

      Some::Class->class_method
      $some_variable->method
      $Some::Class::variable->method
      $array_reference->[0]
      $hash_reference->{key}
      $code_reference->(@arguments)
This is to avoid test failures with samples/Raku/hash.t, which is 50%
Raku code and 50% Perl code (embedded as a multi-line string in Raku).
Without the negative 'use v6' pattern, the heuristics would detect the
embedded code as Perl (which it is).
@mauke mauke requested a review from a team as a code owner January 25, 2023 20:59
samples/Perl/Contoso.pm Outdated Show resolved Hide resolved
@Alhadis Alhadis changed the title Tune perl heuristics (see discussion #6263) Tune Perl/Raku heuristics Jan 26, 2023
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

Note: this PR will not be merged until close to when the next release is made. See here for more details.

@lildude lildude merged commit 86c75c0 into github-linguist:master Feb 17, 2023
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants