Results 1 to 5 of 5

Thread: Aliasing

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Aliasing

    After reading an article by one of the Google PH'ds, he stressed the importance of better compiler understanding in relationship to programming. So I'm trying to increase my understanding in this area. Regarding -- How Compilers Work -- I came across this statement.


    One of the most important uses of interprocedural analysis is to obtain so-called alias information. An alias occurs when two names may designate the same variable. For example, it is quite helpful to know that two pointers passed to a function may never designate the same variable. Alias information is almost always flow-insensitive and must be used conservatively.
    QUESTION:
    If you had a global structure and assigned a local variable to one element of this global structure used in a local procedure to make coding easier -- would this be considered aliasing?

    ===================

    For Example:

    Structure Data
    Element1 As Integer
    End Structure

    Procedure local
    Dim j As Integer

    j = Data.Element1 '<< Would this be aliasing???

    End Procedure

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Aliasing

    No, because you're copying the data. Aliasing is, as you probably know.. replacing something with something else. You can't truely use aliasing in Visual Basic.. without proper memory management.

    Theres a few different forms of aliasing, one of which is a typedef in C++, which also isn't available in Visual Basic. Another, as used in the above example, is the use of pointers that are being passed around locally and globally.

    What they say is true though. Its invaluable to know how compilers work, aswell as that of the target architecture.

    During my Game Development Diploma, it became extremely clear to us how important const-correctness was in C++ class design. Since the PlayStation 2 isn't a super computer, anything and everything thats const-correct (read only), is put into a special place in memory, for quick reference. Knowledge like that can - most of the time - be the difference between performance and failure.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Aliasing

    Thanks for response.

    My guess was that it was -- in that a pointer to the structure element would exist and a copy of the pointer would be placed on the stack to this same global structure element. Hence you would have two variables pointing to the same memory location.

    BTW, VB6's Advanced Compiler Options allows you to toggle aliasing.

    Any suggestions for a book describing the compiler Microsoft uses and how it evaluates things?

    Most compiler books and Net research to date has yielded general rather than specific compiler information regarding MS.

    Thanks
    David
    Last edited by dw85745; Dec 21st, 2007 at 07:06 PM.

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Aliasing

    MS are horrible for telling you how their stuff works.

    Visual Basic is a horrible language.. not all of it is compiled code. Theres some interpreted stuff in there too (only like, 3% of the executable.. but still).

    Switch to a proper language

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Aliasing

    Thanks for response.

    chemicalNova.

    I for one like VB -- but you're right alot of things are hidden. For example while you can't directly declare and use a pointer in VB (some might debate this), Classic VB by default is ByRef rather than ByVal. VBNET on the other hands default is ByVal.

    "My" interpretation of this (never seen it discussed) is that Classic VB is using pointers by default, whereas in NET in order to have a common engine, they changed VB (to NET) to be more like C, C++, where you have to explicitly declare a pointer (ByRef).

    Whether I am blowing smoke on this one is unknown!!!!!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width