Re: Poor VB Programming

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Mark J. McGinty (mmcginty_at_spamfromyou.com)
Date: 09/25/04


Date: Sat, 25 Sep 2004 02:45:52 -0700


"Ralph" <msnews.20.nt_consulting32@spamgourmet.com> wrote in message
news:edciSRpoEHA.3428@TK2MSFTNGP11.phx.gbl...
>
[snip]
>>
>> How in the hell can a language allow redefinition of internal symbols?!
>> I
>> am shocked and amazed... So one module with a few insanely written lines
>> could make an entire project utterly nightmarish:
>>
>> Public Load As String
>> Public Unload As Long
>> Public App As Single
>> Public Forms As Integer
>> Const InStr = "reality was stolen, sanity has no meaning, welcome to
> the
>> twilight zone"
>>
>> I think I'm going to script a regexp search for any declaration syntax,
>> using each reserved word, before I accept even one more existing VB code
>> base as a project!
>>
>> My mind is blown... seriously!
>>
>> -Mark
>>
>
> If you are talking about "Now()", then don't get too upset as it is not an
> "internal symbol" - it is a Function that returns a Date Variant. There is
> a
> quirk in VB that allows functions that don't take parameters to not
> require
> the parentheses.

A function is a symbol. Now is part of the VB runtime, is it not? Seems
pretty internal to me... perhaps not the best choice of words, but still not
fundamentally inaccurate.

> Almost all languages allow you to redefine library procedures - at your
> own
> risk of course - but allowed.

Yes that's true but most won't allow you to do it by accident. C will not
allow you to declare a given "symbol" (as in function or variable
identifier, represented by the linker in the "symbol table", thus my
tendency to use the word "symbol") more than once in the same scope, so if
you want to replace a runtime function you must omit the lib in which it
resides from the link list.

T-SQL will not allow you to name a user variable that starts with @@, that
prefix is reserved for system variables, sometimes referred to as "internal"
because they are a built-in part of the environment.

C++ is somewhat more flexible, it that it will allow you to redefine
arithmetic operators in some cases, but not everything in C++ is
overridable, there are rules, it'd be pretty difficult to override something
by accident.

For VB to allow this is inconsistent, it won't let you name two public
functions or subs the same thing within a project, to do so causes an
"ambiguous name detected" error. Clearly standard runtime functions share
the same namespace, why is it less than ambiguous to redefine one of them?

-Mark



Relevant Pages

  • Re: Poor VB Programming
    ... Yes that's true but most won't allow you to do it by accident. ... you want to replace a runtime function you must omit the lib in which it ... it that it will allow you to redefine ... overridable, there are rules, it'd be pretty difficult to override something ...
    (microsoft.public.vb.database)
  • Re: Poor VB Programming
    ... Yes that's true but most won't allow you to do it by accident. ... you want to replace a runtime function you must omit the lib in which it ... it that it will allow you to redefine ... overridable, there are rules, it'd be pretty difficult to override something ...
    (microsoft.public.vb.database.ado)
  • Re: Poor VB Programming
    ... Yes that's true but most won't allow you to do it by accident. ... you want to replace a runtime function you must omit the lib in which it ... it that it will allow you to redefine ... overridable, there are rules, it'd be pretty difficult to override something ...
    (microsoft.public.sqlserver.programming)
  • Re: redefine and override
    ... >I would like to know what is the difference between redefine and override. ... >I'm reading in a book and here it says a virtual function is one that a ... >do not want a derived class to redefine a particular member function, ...
    (alt.comp.lang.learn.c-cpp)
  • is it possible to override a read only environmental variable like $" ?
    ... But alas it is read only and does not allow me to redefine ... Anyone know how to override a read only setting or circumvent this ... somehow. ...
    (comp.lang.ruby)