In these code samples:

    do ..someMethod(.x)
    // or
    do ##class(some.Class).someMethod(.x)

x is automatically created and initialized.

However, this can be confusing since no prior declaration of x exists.

For clarity reasons, it is recommended that a prior declaration exists. The preferred way here is to use #dim which, even though it will do nothing to create the variable itself, has the advantage that you can declare the type, if any. Therefore, the code above would become:

    #dim x as sometype

    do ..someMethod(.x)
    // or
    do ##class(some.Class).someMethod(.x)

Other possibility

Another possibility is to use set instead:

    set x = something

    do ..someMethod(.x)
    // or
    do ##class(some.Class).someMethod(.x)

However, this works quite differently from #dim:

This check will also look for a prior set declaration and will not trigger in this case.