Re: Include Statement
- From: "Herfried K. Wagner [MVP]" <hirf-spam-me-here@xxxxxx>
- Date: Tue, 5 May 2009 22:53:52 +0200
"Mike" <unknown@xxxxxxxxxx> schrieb:
This is done automatically by the VB compiler, so there is no need to do it manually.
Do what? IMO, you are limiting your mind to one way of doing things. A silly idea that "includes" are not useful is that same silly idea you said arrays are not useful in MOST cases.
If you would not quote my post incompletely the answer to your question would already be included.
Remember it is VB.NET that is learning from C/C++ concepts. If it can learn how to do inclusive increments,
string += string
and it learn compiler directives, it can also learn do a #include idea.
Well, it could even learn inline assembler, couldn't it?
In programming language design the language designer makes a decision between different concepts which can be used to achieve a certain goal, based on an evaluation of these concepts. The '#include' concept is a rather low-level concept. Thus it's not present in many "younger" programming languages like Classic VB, Java, and .NET.
Interestingly the demand for this feature is practically non-existent, basically for the reason that there are now other ways to achieve the same goal as with the rather limited text-based '#include' approach.
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.
huh? Like what?
Re-read what I have written and you'll find the answer there. Hint: Looking for declarations. I really wonder if I'll see a thread here about re-introduction of forward declarations in the VB group, for the reason of adding well-known C/C++ concepts to VB. (BTW, I am aware that '#include' is used for additional purposes in C/C++).
Also, lets distinguish VB.NET as oppose VB. Different animals.
My terminology:
VB.NET = VB.
Classic VB = VB1 to VB6, VBA
ASP.NET applications differ in structure from the typical project which is compiled into one binary file.
What does that have to do with Include ideas?
It was /you/ who mentioned ASPX files!
And this does not?
#const USE_VERSION = 1
#if USE_VERSION = 1 then
#include "version1.inc"
#elseif USE_VERSION = 2 then
#include "version2.inc"
#else then
#error "USE_VERSION not defined"
#end if
Could you show a real world sample?
I already mentioned the reason why it is not necessary.
No, you did not.
I did, but you didn't (want to?) read it.
In C/C++ '#include' is the typical way to make information from one file available to another one.
And why isn't that useful for VB.NET
Because it's not necessary, because it's done by the compiler. I already mentioned that.
> In C/C++ you even have to write forwarddeclarations
Hogwash. Not related at all.
Just quote what I wrote in context in future.
and so on because the help the compiler provides in this regard is rather limited compared to the work the VB compiler does.
Man, and you are an MVP?
Wow, that's a perfect technical argument, isn't it?
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.
What if I don't want to? But even then. Its besides the point.
It's the preferred way in VB. If you do not want to use VB, kindly use another programming language.
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.
But its ok for ASPX?
I already said that ASP.NET uses a different compilation/execution model than project types which are compiled to a single binary.
Code Duplication? How about library references? How about the idea of single sourcing?
I was referring to C/C++. This would have been clear if you would have quoted me preserving the context.
You can have class files and a main
' file: class1.vb
class MyClass1
..
end class
' file: class2.vb
class MyClass2
..
end class
' file: main.vb
Module Module1
Sub Main()
End Sub
End Module
with no namespace requirements and compile it like
vbc main.vb class1.vb class2.vb
which is basically the same ideas of having:
#include "class1.vb"
#include "class2.vb"
Module Module1
Sub Main()
End Sub
End Module
Please, I think you mind is molded about GUI IDE development and now power programming console development methods. Its a side note, but the IDE does blind people of programming methods.
Most of the existing VB code is written in VS. Thus the language is optimized for a modern IDE. Nevertheless, as your first above sample demonstrated, it's even possible to get to the exact same result of what's shown in your second sample in VB, even by manually compiling via the command line compiler.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
.
- References:
- Include Statement
- From: Mike
- Re: Include Statement
- From: Herfried K. Wagner [MVP]
- Re: Include Statement
- From: Mike
- Re: Include Statement
- From: Herfried K. Wagner [MVP]
- Re: Include Statement
- From: Mike
- Include Statement
- Prev by Date: Re: Include Statement
- Next by Date: Re: Include Statement
- Previous by thread: Re: Include Statement
- Next by thread: RE: Include Statement
- Index(es):
Relevant Pages
|