Skip to content

Limbering Up: Killing Comments

Vector 18:2, page 43

programming techniques development practice

Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 43

(The purpose of this column is to work some flab off your APL midsection. Like muscles, your APL skills can atrophy if not exercised with adequate frequency and variety. This column presents a task for you to perform. Set aside a few minutes from your busy schedule and work the task. Mail in your solution and stay tuned for the results.)

Ill-disciplined APL programmers rationalise their failure to include comments with statements like, "Comments make my functions too big. I hate to waste valuable workspace on useless comments."

You can argue that comments are never useless, or that comments don’t consume much workspace, but your arguments are likely to fall on deaf ears.

Your better bet is to provide the lazy sceptic with a utility function that eliminates the comments from any specified user-defined function. They say, "Include plenty of comments in your functions and save them in a ‘development workspace.’ Use this utility function to eliminate all comments from the functions and save them in a ‘production workspace.’ You’ll have one workspace that is big and readable and easy to maintain, and another that is small and unreadable and streamlined for running."

Your task is to design and write a function named UNCOMMENT that eliminates the comments and all-blank lines from a specified function. Use ⎕CR to convert the function to its character matrix representation; manipulate the character matrix to eliminate its comments and all-blank rows; and use ⎕FX to convert the character matrix back to a function. See the PRIMITIVE POINTERS section for some hints.

The function should be efficient, but extreme efficiency is not needed since the function will be used during the development process, not during production. And, by the way, your function should contain lots of comments.

Send your solutions to:

Vector Production
Brook House
Gilling East
York YO62 4JJ
UK email: apl385@compuserve.com

The notable functions and their authors’ names will be printed in the next issue of Vector. Good luck and happy limbering.