Case sensitive Visual Basic!

by Michael S. Kaplan, published on 2006/04/11 03:11 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/04/11/572838.aspx


Ok, we start with the following code -- just paste it into Notepad, and save in UTF-8 or Unicode encoding with a nice generic name like Module1.vb:

Module Module1

    Sub Main()
        Call Pröcedure1()
    End Sub

    Sub Pröcedure1()
        Console.WriteLine("Schrödinger's cat is not dead.")
    End Sub

    Sub PRÖCEDURE1()
        Console.WriteLine("Schrödinger's cat is dead.")
    End Sub

End Module

 

Compile it in with VBC (1.0, 1.1, or 2.0):

C:\TMP\Sample\CaseSensitiveVB>vbc Module1.vb

Then run the code:

C:\TMP\Sample\CaseSensitiveVB>Module1.exe
Schrödinger's cat is dead.

The appearance here is that VB is not only allowing function names that vary in no way other than case to co-exist, but also that will appear to be calling the wrong function sometimes!

Hmmm.... how did that happen?

I am sure regular readers will know what I did here; it's a bit like that Normalization as obfuscation in C# post, but with the case variation thrown in.

So now VB gets to not only be weirdly obfuscated, it also has lost its case insensitivity!

Doesn't this seem worthy of a fix? Even if it requires a different compiler setting for backcompat with the people crazy enough to code this way, for the sanity of those who didn't want case sensitive VB it seems like a good idea....

(I realize I have thrown down the gauntlet to the VB team to try to get this issue fixed now!)

:-)

 

This post brought to you by "Ö" (U+00d6, a.k.a. LATIN CAPITAL LETTER O WITH DIAERESIS)
(A character that is proud to not be part of the dyslexic heritage that will confuse people between U+00f6 and U+006f!)

 


SE on 26 Aug 2012 2:22 PM:

hehe


Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

go to newer or older post, or back to index or month or day