Syntactic Confectionery Delight | |
PerlMonks |
Request for Comments: More annotations for Perl plugin for IntelliJby hurricup (Pilgrim) |
on Jun 20, 2016 at 19:05 UTC ( [id://1166129]=perlquestion: print w/replies, xml ) | Need Help?? |
hurricup has asked for the wisdom of the Perl Monks concerning the following question: This is a real request for comments and suggestions. If you are using Perl plugin for IntelliJ, you could see that it uses annotations to help working with project and resolve methods, like #@deprecated, #@returns and #@method Currently I'd like to add two more annotations and thinking about the proper format. Variable Types Currently, variable type may be guessed by the plugin by explicit type definition, like my Foo::Bar $var; or by return value, like my $var = Foo::Bar->new(); Perl explicit type has a flaw: you can't specify different types on multiple declarations, only one for all of them, like my Foo::Bar ($var1, $var2, $var3);, what is not really convenient for arguments unpacking, so you need to change compact format to larger and slower multiple shifts. So the idea here is to introduce #@type annotation and unpacking will look like:
For arrayrefs and hashrefs i'd like to use Moose format from isa parameter of has statement: HashRef[Foo::Bar] and ArrayRef[Foo::Bar]. Subs arguments To improve subs signatures on auto-completion and auto-completion itself, I'd like to add #@args annotation, which may provide additional information about sub argument, like type, optionality and named arguments. Example:
This idea is pretty new, so I don't really know what is the best way to do this. Typing format is pretty obvious but other features - not. Optional vs mandatory:
Named parameters looks pretty solid, aside it's not possible to add a description, but not sure how to use it yet anyway. I'm also going to make possible to move all subs annotations to a separate file, like Python stub file, it's necessary to work with external OOP modules, which are not annotated and won't ever be. Please, share your ideas and suggestions.
Back to
Seekers of Perl Wisdom
|
|