Mark Kamoski said:
Hi Everyone.
What is the real difference between writing a Sub versus writing a Function
with no return value?
It seems to me that both of these would need to compile to the same IL, so
it seems they are identical.
When you write code, do you write it based on how you know the IL will
result? The goal is to make your code easier to understand, if the resulting
IL is the same either way, that just makes a better argument to use the
proper mechanisms that are provided by the language. In some cases, you
write your code around IL because you know it will be mucked up other wise
(such is the case of constructors and private field initialization).
Why would you want to only use Functions? This is a step backwards. Here is
another question - Why use Properties if it is only a thin wrapper for a
public field (a property with no validation or logic)? Why use an event when
you can just use a manual Callback via the Win32 API? Why use strong
variable types? Why use Classes & objects, why not just write purely
procedural code? After all IL is just one long list of function calls right?
HTH,
Jeremy