0

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")
    $)
$)
k314159
  • 5,051
  • 10
  • 32

1 Answers1

0

Well, for a start, your syntax appears to be off. From memory, the syntax of test is:

test <expression> then <true-bit> or <false-bit>

Though, since there are many variations on BCPL, you could be using one that allows that syntax.

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

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

If you really want to leave it as is, other than possibly fixing the syntax, any null-type statement (one having no functional effect, such as writes("") or let xyzzy_plugh_twisty = 42) will do. An example of that could be something like:

if bar do $(
    writes("")
$) else $(
    writes("baz*n")
$)
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953