Re: Adding C#-Code to VB-Project in VS 2005 without using DLL



Now there's a question and a half Seth :)

Have you finished the preprocessor yet? :)

How would you envisage it resolving something like:

#Visual Basic

Public Class Foo

#End Visual Basic

#Visual Basic

Public X As Integer

Public Sub VBFoo

x += 1

End Sub

#End Visual Basic

#CSharp

public int x;

public void CSharpFoo()
{
x++;
}

#CSharp

#Visual Basic

End Class

#End Visual Basic

In VB.NET, variable names are case-insensitive, so, logically the dummy would be spat because VB.Net can;t handle 2 variables with the same name having the same scope.

In C#, however, variable names are case-sensitive, so, X and x declared having the same scope is perfectly legal.

The point here is that such a preprocessor, to be of any value would need to break the rules of one language to allow the rules of the other language, and, immediately, that need negates any value that such a preprocessor might have.


"rowe_newsgroups" <rowe_email@xxxxxxxxx> wrote in message news:1171910112.942649.72970@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I know this is slightly off topic, but I'm curious - since both vb and
c# compile to msil, why couldn't the ide use a preprocessor to support
different languages in the same file?

Something like:

#Visual Basic
Public Sub VBFoo()
...
End Sub
#End Visual Basic

#CSharp
public void CSharpFoo( )
{
...
}
#End CSharp

Thanks,

Seth Rowe


On Feb 19, 10:32 am, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@xxxxxx> wrote:
"Stephany Young" <noone@localhost> schrieb:

> Seeing as how you have learned that you can, since VS 2005, add C#-Code > to
> a VB Project, would you please be so kind as to enlighten us. We would > be
> most interested.

You actually cannot, except in Web projects in which you can use different
languages in different script blocks and pages.

--
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: Adding C#-Code to VB-Project in VS 2005 without using DLL
    ... Have you finished the preprocessor yet? ... #CSharp ... break the rules of one language to allow the rules of the other language, ... Public Sub VBFoo() ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Cpp Considered Harmful
    ... > One is to present the 'raw' interface of the template to the user. ... easier than they can parse the underlying language itself. ... resulting from the preprocessor, it merely has to preprocess it. ... > Using JBuilder, and the Java counterpart, I can fly through XML ...
    (comp.lang.cpp)
  • Re: Cpp Considered Harmful
    ... ordering, template declaration instantiation, etc.. ... I think you have a serious misunderstanding of the preprocessor. ... Parsing Java is quite a bit simpler than parsing C++. ... >> source code much easier than they can parse the underlying language ...
    (comp.lang.cpp)
  • Re: Cpp Considered Harmful
    ... That is why assertions are preproccessed away in production code. ... What I've seen done with Java IDEs has shown me that they can ... In C++, because of the preprocessor, you cannot really be sure that what ... that you apparently want to enforce coding policy by language design. ...
    (comp.lang.cpp)
  • Re: Boost Workshop at OOPSLA 2004
    ... There is only one replacement for the c++ preprocessor which I would ... the near future: metacode. ... By this I mean the capability to walk the parse tree at compile time ... proposal but a full language extension). ...
    (comp.lang.cpp)