Language Server Optimisation

Every use of the -> operator, either explicitly or implicitly (when relying on the default connection) requires a message to be sent to the language server, and a reply waited for. But some code sequences do not require a result from the language server, and these code sequences can be optimised by disabling the wait for the reply.

This is done by using the %Set(NoEarlyErrorNotify) special method on the connection object. This has the effect that only statements that consume the result of an object method will wait for a result. %Set(EarlyErrorNotify) restores the default position.

It is quite safe to set the NoEarlyErrorNotify option immediately after a connection to run the complete program in optimised mode, but note that exceptions generated by methods may not be noticed immediately, and debugging code in this state may be confusing.

Examples

In the following example CurrentRate consumes the result of the Loan.getInterestRate() method and so will always wait for the result of the method call.

CurrentRate = Loan->getInterestRate()

By default, the following requires two language server calls and waits:

Methods = BankAccount->getClass()->getMethods()
Document->open("jpg")

But with NoEarlyErrorNotify set, only the first waits for a result from the language server (to complete the assignment).

%Set(NoEarlyErrorNotify)
Methods = BankAccount->getClass()->getMethods()
Document->open("jpg")

If Document->open() causes an exception, any exception thrown will not be noticed until the next result is returned from the language server. To overcome this, a simple dummy assignment can be used:

%Set(NoEarlyErrorNotify)
Methods = Obj->getClass()->getMethods()
Dummy = Document->open("jpg")

Programs run with NoEarlyErrorNotify set should always end with a dummy (or actual) assignment to ensure any errors generated are caught.

See also

%Set