Suppose that an expression like

f[something, 12]


was sent to a MathLink link, and we need to read off only the second part of f, which has a known type (e.g. integer). How can the first part, something, be discarded? something could be an atomic or compound expression of any kind. I need to do this in C.

Example:

int argc = 2;
// fail
}

// how do I discard the complete next expression here, whether it's atomic or compound?

int i;
MLGetInteger32(link, &i); // get the integer

• Should I transfer it to a loopback link, then get rid of the loopback link? – Szabolcs Oct 18 '15 at 18:49
• Hmm, I've completely forgotten about this. I think the right way might be MLTransferExpression(NULL, link), but haven't tried yet. – Szabolcs Oct 18 '15 at 20:08

Based on Todd Gayley's response here and trying it out, it can be done using

MLTransferExpression(NULL, link)


This will remove one complete (sub)expression form the link.

The code for the example from the question would be

int argc = 2;