rasciispecial-charactersdelimiter

What are some practical applications of the formfeed character in R source code?


The manuals [3], including the R Language Definition [1] and Writing R Extensions [2] state "whitespace characters [including] formfeeds... serve to delimit tokens in case of ambiguity" [1] and "Only ASCII characters [including] formfeed... should be used in code files" [2].

When might the use of formfeed in sourcecode be advantageous?

How do typical text editors interpret formfeed?

I typically use Vim. Formfeed seems to appear as ^L, and does not seem to have an effect analogous to form feed on a printer.

In the RGui (R 3.5.3), cat places a box-shaped character when formfeed is encountered (using Courier New font on Windows 10).

[1] R Core Team (2016-06-21) R Language Definition, v3.3.1

[2] R Core Team (2019-07-05) Writing R Extensions, v3.6.1

[3] https://cran.r-project.org/manuals.html


Solution

  • Quite a few programming languages allow form feed as a legal whitespace character. An incomplete list:

    In all of these languages whitespace it’s just part of the whitespace set. So the form feed character has no real significance other than delimiting tokens. (Note Python though)

    You can of course make use of it informally. And since form feed is the “next page” character, some language communities have decided to use form feed as a sort of section delimiter. Something like this:

    <function>
    
    <function>
    
    <function
    
    <form feed>
    <function>
    
    <function>
    

    This has been the case in Emacs Lisp source code. I don’t know if it is still practised.

    R

    I found nothing to indicate that this is a practice in the R community. So I conclude for now that form feed has no significance in R programming practice. It seems to just be one of the allowed whitespace characters.