tags:

views:

48

answers:

2

I want to write a subroutine for working out what to do and then returning.

Before you jump on the "A subroutine that returns is a function LOL!" bandwagon, I want the return to be executed as it were in the function body calling the subroutine, as though I've got a preprocessor to do the substitution, because otherwise this codebase is going to get unwieldy really fast, and returning the return value of a function seems kludgy.

Will vb (sorry I can't be more specific about what version- I'm writing formulas for an embedded system, our API docs are "it runs vb") let me do that or fall in a heap?

+1  A: 

I want the return to be executed as it were in the function body calling the subroutine, as though I've got a preprocessor to do the substitution, because otherwise this codebase is going to get unwieldy really fast, and returning the return value of a function seems kludgy.

It's not. Tail-calls are a common practice that work just fine.

They are much preferable than having a function that cannot ever be called unless you want to return its value.

Anon.
The function will be useless in any other context. The next most preferable option is implementing my own preprocessor to substitute the macro in. Thanks though, I may go with that in the meantime to get it working, since if nothing else if implemented properly they should be a bit interchangable.
Richo
A: 

It sounds like you are asking whether C/C++ style macros can be implemented in VB, the answer is no. You could possibly fake it though by generating vbscript, and substituting the right things in.

Lambdas and delegates in VB.Net are not really the same thing as what you are asking for - if my interpretation is correct.

slugster