Search code examples
bcpl

How to write an empty block


How do you write an empty block? For example, in C, you can have { }. But in BCPL, the equivalent $( $) is a syntax error because a block needs at least one statement. So how can you make the following compile?

let foo() be $(
    test bar then $(
        //to do
    $) else $(
        writes("baz*n")
    $)
$)

Solution

  • For now, you could just switch to unless to achieve the desired result:

    // TODO: refactor to use "test", and code other case.
    unless bar do $(
        writes("baz*n")
    $)
    

    If you really want to leave it as is, any null-type statement (one having no functional effect) will do. An example of that could be something like:

    test bar then $(
        // TODO: replace with real code later.
        bar := bar
    $) else $(
        writes("baz*n")
    $)