Thread overview
this * for struct methods versus inout this
Jul 08, 2003
Burton Radons
Jul 08, 2003
Sean L. Palmer
Jul 08, 2003
Burton Radons
Jul 10, 2003
Sean L. Palmer
Jul 28, 2003
Farmer
July 08, 2003
When in a struct method, the "this" is a pointer to the struct.  It'd be better for language leveraging, some clumsy syntax with operator overloading, and consistent syntax if "this" were an inout reference instead.

July 08, 2003
Why would you ever want a class method to be able to change its 'this' pointer?  C++ makes this const for a good reason.

Sean

"Burton Radons" <loth@users.sourceforge.net> wrote in message news:bedj00$20vt$1@digitaldaemon.com...
> When in a struct method, the "this" is a pointer to the struct.  It'd be better for language leveraging, some clumsy syntax with operator overloading, and consistent syntax if "this" were an inout reference instead.


July 08, 2003
Sean L. Palmer wrote:
> Why would you ever want a class method to be able to change its 'this'
> pointer?  C++ makes this const for a good reason.

I'm not talking about "this" in class, only about struct.  This is currently how it's done:

struct vec3
{
   vec3 mulass (vec3 other)
   {
      return *this = *this * other;
   }
}

Pointers can be more than one cell in length, can be null, and can be re-assigned.  "this" in struct is invalid on all counts:

   void foo ()
   {
      vec3 bar;
      if (this === null) /* Never true */
      this [1]; /* Invalid */
      this = &bar; /* Invalid */
   }

July 10, 2003
You're saying it should be a reference instead of a pointer.

I agree.

Sean

"Burton Radons" <loth@users.sourceforge.net> wrote in message news:befel6$qo1$1@digitaldaemon.com...
> Sean L. Palmer wrote:
> > Why would you ever want a class method to be able to change its 'this' pointer?  C++ makes this const for a good reason.
>
> I'm not talking about "this" in class, only about struct.  This is currently how it's done:
>
> struct vec3
> {
>     vec3 mulass (vec3 other)
>     {
>        return *this = *this * other;
>     }
> }
>
> Pointers can be more than one cell in length, can be null, and can be re-assigned.  "this" in struct is invalid on all counts:
>
>     void foo ()
>     {
>        vec3 bar;
>        if (this === null) /* Never true */
>        this [1]; /* Invalid */
>        this = &bar; /* Invalid */
>     }


July 28, 2003
Burton Radons <loth@users.sourceforge.net> wrote in news:befel6$qo1$1@digitaldaemon.com:

> Pointers can be more than one cell in length, can be null, and can be re-assigned.  "this" in struct is invalid on all counts:
> 
>     void foo ()
>     {
>        vec3 bar;
>        if (this === null) /* Never true */
>        this [1]; /* Invalid */
>        this = &bar; /* Invalid */
>     }
> 
Actually, "this" can be null, especially since Walter allowed allocation of structs with new.

Of course, I agree that making "this" should be an inout reference.


Farmer.