-
-
Notifications
You must be signed in to change notification settings - Fork 75
Perl syntax nuances
Alexandr Evstigneev edited this page Jul 27, 2015
·
14 revisions
Because of incremental nature of IDEA lexer and Perl's heavy context dependency, there are few nuances in Perl syntax for Camelcade plugin:
- Avoid too much of Perl's magic. Perl allows you to do a lot of things. And they might work. And sometimes not as intended. So - be straight, strict, simple, obvious and explicit. No code like this:
DynaLoader::bootstrap Math::MPFR $VERSION;
Perl is ambiguous enough, to add more. Plugin created to develop a product, not for Perl acrobatic.
- Camelcade is less forgiving than Perl. But nothing critical. For example, you can't write:
push @array, $value, if $some_condition;
Perl eats this but Camelcade wouldn't like tailing comma. This is one of the restriction left intentionally to bring some order into the mess.
- You can't use anonymous hash in the beginning of statement. For example:
sub somesub{
{
key1 => 'val1',
key2 => 'val2',
}->{$keyvar};
}
Is pretty valid from Perl's perspective. But Camelcade requires something before it (like return in this case).
- If some package is not being parsed correctly (like
Foo::Bar->methodbeing parsed asFoo::Bar()->method, you may explicitly specify that it's a package:Foo::Bar::->method. Don't forget report a bug with code example. - Use
m/PATTERN/form of match regexp. Implicit form/PATTERN/is supported, but not always being parsed correctly. For example, aftergrep/map/sort {}you MUST usem//form. Better to use it all the time. Implicit form of?PATTERN?is not supported in any way. Usem?PATTERN?. -
ourvariables should be declared at least once. You may refer them later as$package::var, but to make re-factoring works properly you must declare them somewhere. - Try to avoid using 'fancy' object method calls
method Foo::Bar. Use canonicalFoo::Bar->method. Fancy usage is supported, but may be glitchy. - If your project contains XS subs, declare them with prototypes in pure Perl. Plugin may find such declarations and has no any access to XS parts.
- Currently only ascii identifiers are supported, you can't use non-ascii symbols in identifiers (TBF).
- Empty heredoc markers are not supported (TBF).
- Multiple heredoc openers in one line are not supported (TBF).
- Camelcade actively using type in variable declaration:
my Foo::Bar $foo_bar_object. Types helps to resolve methods.
- Home
- Getting started
- Features
- Languages & Frameworks
- Integration
- Version Managers
- Misc