Newlines in .func body, and nesting .func?

For fun I have implemented the simple analytical mosfet equations. The result is in MOSFET4.qsch attached here. I learned that .func command can clean up the schematic compared to using behavioral sources. But you can see in MOSFET5.qsch that this results in a really long function.
It would be a lot easier to read if it was broken up over several lines. But the output window tells me bad function syntax if I try to break it up with CTL-M newlines. Is this expected?
Another .func question is nested calls - should I expect a function call from inside another function to work?
Why does MOSFET5.qsch run so much slower and also give different results?
(Thanks to kskelvin for his guides on github)
MOSFET4.qsch (10.5 KB)
MOSFET5.qsch (4.2 KB)

Here are the answers to two of your questions:

  1. Break Line in Spice: To break a line into several lines in Spice, you need to add a “+” at the beginning of each new line.
  2. .option LISTPARAM: If you have the “.option LISTPARAM” enabled, it will slow down the simulation. This option prints the parameters in the Output Window. Additionally, if you refer to the C++ template of the DLL device in Qspice, diagnostic print statements have “msleep()” added in their C code. In short, deleting or commenting out the “.option LISTPARAM” will speed up your simulation.

For your reference, I have provided a modified version of MOSFET5.qsch.

MOSFET5.qsch (4.2 KB)

I learned that:

  1. the function argument names in the function definition can’t conflict with a parameter. I thought the scope of a function argument names was kept local. My mistake was relying on “global” scope for the parameters I wanted but also assuming the arguments would be unique.
  2. calling a function in the waveform viewer won’t respect the given argument if it conflicted in the schematic.
    Thanks for your help!