Friday, 5 October 2012

Comments

SFPL Comments

Tomorrow I will forget how something I wrote today works. This is why we have comments.

SFPL has a carefully designed commenting system which goes beyond those of many other languages (which, in effect SFPL is). However, they are also really simple.

To create a comment just use [ write something here ]

Anything between square brackets will be ignored by SFPL. Also, comments can be placed inside comments (unlike /* */ comments in C for example) and comments can span many lines:

[ this is a comment]
[ this is a comment [ with a comment inside it ]]
[
  this
  ===
  is
  a
  multi-line comment
]

One thing which is not a comment is  this

Monitor[ monitor the singal ]

SFPL will think we are trying to use a processor called Monitor[ ; the correct layout is:

Monitor [ monitor the singal ]

If you are a language minded sort of person then we could say "comments must start with a new token"

Why do we have comments inside comments? Sometimes we want to be able to turn off chunks of patch whilst we are working on a performance. For example
?make-tuneA Do !tune-a-do
?make-tuneB Do !tune-b-do
(
    >tune-a-do,
    >tune-b-do
)DoAll Mix !signal
?reverberate Do Done !signal [ add reverb - this takes a long time ]
>signal Monitor
If we are just working on the tune, running the reverberation each time we want to listen to the result might be a waste of time so we can just 'comment out' that bit:


?make-tuneA Do !tune-a-do
?make-tuneB Do !tune-b-do
(
    >tune-a-do,
    >tune-b-do
)DoAll Mix !signal
[?reverberate Do Done !signal [ add reverb - this takes a long time ]]
>signal Monitor

Because comments can be nested, it does not matter that we have a comment inside a comment. This is a very powerful and easy to use trick in SFPL.

No comments:

Post a Comment