1. Sequence allocation

Simple, if I define a sequence named "s1":

s1 = {1,2,3,4,"whatever..."}

then define another sequence, "s2"

s2 = {s1,"other stuff"}

Will s2 contain a copy of s1 as its first element, or a pointer to s1. I'm using
this kind of example in a test I'm doing. But I don't want to use this approach
if s1 actually gets *replicated* into the first element of s2, as a lot of space
will get wasted if there are a lot of s2 like sequences lurking around! :)

 If anyone with a clue more than myself can tell me it'd be much appreciated

Cheers
!



Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at
http://www.eudoramail.com

new topic     » topic index » view message » categorize

2. Re: Sequence allocation

On Fri, 21 Jul 2000 00:45:10 +1200, F Dowling <dobehe at EUDORAMAIL.COM> wrote:

>Simple, if I define a sequence named "s1":
>
>s1 = {1,2,3,4,"whatever..."}
>
>then define another sequence, "s2"
>
>s2 = {s1,"other stuff"}
>
> Will s2 contain a copy of s1 as its first element, or a pointer to s1.
> I'm using this kind of example in a test I'm doing. But I don't want
> to use this approach if s1 actually gets *replicated* into the first
> element of s2, as a lot of space will get wasted if there are a lot
> of s2 like sequences lurking around! :)

AFAIK, the answer is the latter; the pointer is copied. This changes it if
you change any of the elements of s1 or s2[1]; A copy must be made at that
time.

To go one level deeper though:
    Since s1[5] is a sequence, only the _pointer_ to that sequence would
need to be copied (providing that isn't the element you change), so you
won't have lots of "whatever..."s floating around either.

Euphoria is a very, very clever language when it comes to things like this.

HTH,
Carl

new topic     » goto parent     » topic index » view message » categorize

3. Sequence allocation

Oops!

In my previous post
the line s2=s1&{4,5,6} should read s2={s1,4,5,6} and the following line
should be s2[4]=0

In the I cited, s1 is not being inserted into a sequence, its elements are,
and since they are integers, they will be copied.  My origianl example would
still be workable if the elements of s1 were not integers.

By the way, I forgot to add in my previous post that this integers and
pointers representation of sequences is the reason that Euphoria is limited
to 31-bit integers in a 32-bit environment:  one bit is used as a flag to
indicate a pointer.

-- Mike Nelson

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu