in reply to Re: Ordering of parameters - Re^9: Converting Unicode
in thread Converting Unicode
Any time I go beyond 5 parameters I make it into an object. That's all objects are really: a collection of named pieces of data, along with the functions that operate on them. Then, the attribute accessors help you avoid typos. If you know the names of all the variables upfront, then an object (or collection of objects) are the way to go. If the variables are dynamic, then yes just pass them around as a hashref. Or, do some clever hybrid of the two ideas if you have a special use case.
Raku does in fact solve many of the pain points of Perl 5. That's its reason for existing. The reason many Perl 5 people did not jump on board was simply because of performance, and that it doesn't really carry forward the ecosystem of existing perl 5 modules. (Raku can use Perl 5 modules, but they are slower than native raku code, so that kind of implies that every existing module ecosystem ought to get rewritten into Raku) Also, many of us are perfectly satisfied with the tools we have available, and the minor feature gains don't justify the migration cost.
If you want to solve your problems with Raku, then more power to you! If you are genuinely wondering why this crowd is satisfied with the features and warts of Perl 5 when it comes to problems like yours, then maybe you should make a large semi-anonymized example as a new post and ask "how would you solve this"? ...and then take the answers as a thing to study, instead of attack. I, for one, am using Perl 5 because I have not yet found a problem that it couldn't handle well, and it gives me the choice to solve the problem extremely quickly (toss hashrefs around) or very properly (object hierarchy and type libraries) or very performantly (using XS or Inline::CPP) or any combination I want within that triangle. I've tried many other languages and none have provided that versatility.
(technically I'm cheating by using C, because that's a second language. but it integrates very nicely with Perl)
Edit:
Any time I go beyond 5 parameters...A lie. As I concluded, sometimes I play fast and loose, and other times I aim for more structure. It should read: "Any time I go beyond 5 parameters I think to myself that I should probably be using an object, and consider which of these parameters would make the most sense as an object, or whether they should get included as attributes in the current object, and whether I want to spend that much time refactoring".
|
---|
Replies are listed 'Best First'. | |
---|---|
A reply falls below the community's threshold of quality. You may see it by logging in. |