Re: Include Statement

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Mike" <unknown@xxxxxxxxxx> schrieb:
Maybe I missed this because I can't find it, but is there and "include sourcefile" statement in VB.NET? example

'MainProgram.vb

imports system

module module1

#include "some_common_stuff.vb"
#include "useful_classes.vb"

sub main()
end end

end module

I mean, this is standard stuff in the other .NET languages? No?

No, there isn't, because it's not necessary in languages like VB and C#.

Who says? Gawd, I hate this closed indset.

The VB compiler works in an other way than C/C++ compilers, for example.

Typically includes have been used in C/C++ to make functionality defined in another file available in another file (I do not use C/C++ terminology here because I am not sure if you are familiar with C/C++). This is done automatically by the VB compiler, so there is no need to do it manually.

Types defined in another source file belonging to the project can be accessed *directly* if the namespace they reside in is imported and the types' visibility settings grant permission to access the types/members. No need for forward declarations!

So why do other .NET, like C++ languages support a simple include concept? Including VB ASPX files?

The C++ compiler doesn't do all the work for you which the VB compiler does. ASP.NET applications differ in structure from the typical project which is compiled into one binary file.

I mean, this is yet another case where VB.NET attempts to inherit standard compiler concepts, but fails to do go all the way, only does for a few things. For example, existing compiler directive

#const USE_VERSION = 1

#if USE_VERSION = 1 then
some v1 code
#elseif USE_VERSION = 2 then
some v2 code
#else then
#error "USE_VERSION not defined"
#end if

Very powerful ideas for programmers. Don't tell me it "isn't necessary."

This is supported in VB.NET because it makes perfect sense even in VB.NET!

If VB.NET support these compiler directives, there is no reason why it couldn't do #include.

I already mentioned the reason why it is not necessary. In C/C++ '#include' is the typical way to make information from one file available to another one. In C/C++ you even have to write forward declarations and so on because the help the compiler provides in this regard is rather limited compared to the work the VB compiler does.

BTW, the '#include' concept of C/C++ is rather low-level and not very comfortable to use.

Adding a standard #include concept isn't going to change anything regarding name spaces and that wouldn't be the purpose, but in fact, it could very useful in quickly creating new namespaces out of include files

namespace MyNewNameSpace
#include "class_dispose.vb"
#include "class_music.vb"
#include "class_whatever.vb"
end namespace

Just add the namespace declaration on each of the files. No need to use text-based inclusion of other files. Code duplication, which was one of the top reasons for using '#include' in C/C++ isn't required and it would not work in VB.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

.



Relevant Pages

  • Re: C/C++ Compilers Optimization Failed
    ... I used C/C++ Compiler's Optimization. ... >> xor eax, eax ... I am shocked that C/C++ Compiler did not tune optimization very well ...
    (comp.lang.asm.x86)
  • Re: Performance : COBOL trounces C / C++?
    ... When contracting to various ISV's I've had occasion to speed up C/C++ ... ported to z/OS or newly written under z/OS. ... if correct compiler options set, ... Before Tom Ross puts a contract out on me I am not claiming COBOL is slower ...
    (bit.listserv.ibm-main)
  • Very strange problem with namespace
    ... reference that is returned by an iterator. ... No matter what, the compiler ... contains item_proxy as an inner class) is not defined in namespace N, ... // without putting ContainerFront into namespace N ...
    (microsoft.public.vc.language)
  • Re: How to fix awkward ATL namespace clash?
    ... Renaming my own namespace doesn't work because I'm not getting a namespace ... I'm getting an Interface collision. ... By the time the compiler parses my typelib the OLEDB IAccessor ...
    (microsoft.public.vc.atl)
  • Re: Python doesnt know class of function ? : class C:def f():pass;l=[f]; print C.l[0].im_class
    ... So, when iterating the list in my test compiler, i need to know if the ... I think when python compiles the TG class, ... testA thing is in class TG namespace ... or so to the class namespace locals(). ...
    (comp.lang.python)