November 17, 2004
On Tue, 16 Nov 2004 12:36:16 +1300, Regan Heath <regan@netwin.co.nz> wrote:

> On Tue, 16 Nov 2004 00:09:55 +0100, Sjoerd van Leent <svanleent@wanadoo.nl> wrote:
>> Regan Heath wrote:
>>> On Mon, 15 Nov 2004 16:22:57 -0600, Garett Bass <gtbass@studiotekne.com> wrote:
>>>
>>>> Personally, I find the Java approach with object.clone() and interface
>>>> Clonable very appealing.
>>>
>>>
>>> Correct me if I'm wrong, but java does not have pointers, right?
>>> Regan
>>>
>>
>> You're wrong. All types in Java *are* pointers. Only primitives (i.e.: int, boolean, double) are not.
>
> I thought they were 'references'?
>
> Regan
>

As in, you cant go
<code>
SomeClass* pCurrentObj = someObjArray[0];

do {
	something(pCurrentObj++);
while(pCurrentObj);
</code>

(this assumes of course that the array is null terminated)

and other DangerMouse things like that.

Now, if you have anything with pointers in a non-legacy structure, is it not
likely that they are to keep track of someone elses object? If you own
an object and just dont want to continously carry it around, you use
references instead, right? (of course, it's mostly code style)

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
November 17, 2004
On Wed, 17 Nov 2004 21:28:54 +1300, Simon Buchan <currently@no.where> wrote:
> On Tue, 16 Nov 2004 12:36:16 +1300, Regan Heath <regan@netwin.co.nz> wrote:
>
>> On Tue, 16 Nov 2004 00:09:55 +0100, Sjoerd van Leent  <svanleent@wanadoo.nl> wrote:
>>> Regan Heath wrote:
>>>> On Mon, 15 Nov 2004 16:22:57 -0600, Garett Bass  <gtbass@studiotekne.com> wrote:
>>>>
>>>>> Personally, I find the Java approach with object.clone() and interface
>>>>> Clonable very appealing.
>>>>
>>>>
>>>> Correct me if I'm wrong, but java does not have pointers, right?
>>>> Regan
>>>>
>>>
>>> You're wrong. All types in Java *are* pointers. Only primitives (i.e.:  int, boolean, double) are not.
>>
>> I thought they were 'references'?
>>
>> Regan
>>
>
> As in, you cant go
> <code>
> SomeClass* pCurrentObj = someObjArray[0];
>
> do {
> 	something(pCurrentObj++);
> while(pCurrentObj);
> </code>
>
> (this assumes of course that the array is null terminated)
>
> and other DangerMouse things like that.

Yes (whether it's 'dangerous' or not is beside the point)

> Now, if you have anything with pointers in a non-legacy structure, is it  not
> likely that they are to keep track of someone elses object?

It could be, what about ..

struct big {
 .. lots of members ..
}

class Foo {
  big *one;

  Foo() {
    one = null;
  }
  ~Foo() {
    if (one) {
      delete one;
      one = null;
    }
  }

  void read_the_one(File f) {
    one = new big();
    ..read data from file..
  }
}

in other words a large struct (used for it's memory layout and lack of vtable etc) which is not always in existance, i.e. only created when necessary.

> If you own
> an object and just dont want to continously carry it around, you use
> references instead, right? (of course, it's mostly code style)

Unless it's a struct, as above.

Regan

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
1 2
Next ›   Last »