8 Apr 05:29
Re: Array question
From: Ian Piumarta <piumarta@...>
Subject: Re: Array question
Newsgroups: gmane.comp.lang.smalltalk.fonc
Date: 2008-04-08 03:29:38 GMT
Subject: Re: Array question
Newsgroups: gmane.comp.lang.smalltalk.fonc
Date: 2008-04-08 03:29:38 GMT
Hi Dan,
> (from function/objects/Array.st):
>
> Array size_: _size value_: _value
> [
> self := self new: (SmallInteger value_: _size).
> _oops := _value.
> {
> int i;
> for (i= 0; i < (int)v__size; ++i)
> ((oop *)self->v__oops)[i]= *((oop **)v__value)[i];
> }.
> ]
This is the constructor that the compiler invokes implicitly whenever
you write an Array literal "#( ... )" in a program. The argument
_value points to a C array of oops corresponding to "..." in your
constant and _size is an int reflecting the number of entries in the
C array.
> What is that "_oops := _value." doing?
_oops is an instance variable of the receiver, which by line 2 is a
new Arrray of size _size. The line in question makes the C array
containing "..." be the contents of the Array object.
Cheers,
Ian
RSS Feed