Refactoring MATLAB

  • Authors:
  • Soroush Radpour;Laurie Hendren;Max Schäfer

  • Affiliations:
  • Google, Inc., School of Computer Science, McGill University, Montreal, Canada;School of Computer Science, McGill University, Montreal, Canada;School of Computer Engineering, Nanyang Technological University, Singapore

  • Venue:
  • CC'13 Proceedings of the 22nd international conference on Compiler Construction
  • Year:
  • 2013

Quantified Score

Hi-index 0.00

Visualization

Abstract

Matlab is a very popular dynamic "scripting" language for numerical computations used by scientists, engineers and students world-wide. Matlab programs are often developed incrementally using a mixture of Matlab scripts and functions, and frequently build upon existing code which may use outdated features. This results in programs that could benefit from refactoring, especially if the code will be reused and/or distributed. Despite the need for refactoring, there appear to be no Matlab refactoring tools available. Furthermore, correct refactoring of Matlab is quite challenging because of its non-standard rules for binding identifiers. Even simple refactorings are non-trivial. This paper presents the important challenges of refactoring Matlab along with automated techniques to handle a collection of refactorings for Matlab functions and scripts including: converting scripts to functions, extracting functions, and converting dynamic function calls to static ones. The refactorings have been implemented using the McLab compiler framework, and an evaluation is given on a large set of Matlab benchmarks which demonstrates the effectiveness of our approach.