Re: Sequence allocation

new topic     » goto parent     » topic index » view thread      » older message » newer message

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu