jmmitc06 has asked for the wisdom of the Perl Monks concerning the following question:
Monks:
I have a large chunk of code where I am doing some heavy mathematical work and I would like to know if there are any options to define what type a variable is in order to avoid alot of the interpreter work with the loose/dynamic variable typing. I know that this is unlikely given it is a very non-Perl way of doing something but in short I would like to tell the interpreter that variable $foo is and will always be an integer for example, so don't bother checking if it is anything else. From my understanding, many operations that may be performed on $foo will check the type of the variable before proceeding, deciding how to do the operation.
Additionally, I know that rewriting in another language (C, C++) where this is available by default would provide these advantages, but this is not a good option given that the rest of the program is in Perl and I'm not a programmer by trade, so a C/C++ rewrite will take much longer than implementing the other solution if available. Additionally, it likely won't be a huge benefit in performance but now I'm more interested out of curiosity than anything else.
Thanks in advance for any thoughts on this. As a biochemist without a formal programming background, the PerlMonks site has been a great resource to me in the last few years both from answering the questions I have asked and the volume of stuff available from the questions of others
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Anyway to Have Strong-Like Typing
by kennethk (Abbot) on Aug 11, 2014 at 20:35 UTC | |
by jmmitc06 (Beadle) on Aug 13, 2014 at 04:35 UTC | |
by BrowserUk (Patriarch) on Aug 13, 2014 at 05:57 UTC | |
by etj (Priest) on May 20, 2022 at 15:02 UTC | |
Re: Anyway to Have Strong-Like Typing
by Anonymous Monk on Aug 11, 2014 at 20:55 UTC | |
by AnomalousMonk (Archbishop) on Aug 11, 2014 at 21:22 UTC |