Re: sequence question
- Posted by CoJaBo <cojabo at suscom.net> Sep 04, 2004
- 482 views
Tone Škoda wrote: > > sequence s1, s2 > s1 = repeat (0, 1000000) -- s1 is 3.8MB big > s2 = {{}} > s2 [1] = s1 > > will this last line of code: > 1. make copy of s1 into s2 [1] > 2. or will it only make pointer to s1? 2 > > similar is this: > s2 = {repeat (0, 1000000)} > s1 = s2 [1] -- what happens here? 2 again > > if it is number 1 then it is waste of memory. > in cases like this i like C more because it is more clear what happens. > > i'm asking this because i want to create a library which is not specific for > program. > and in this library one sequence1 appears in many different sequences. i could > only > have one copy of this sequence1, not many same copies which would exist in > these different > sequences. here pointers would be nice. > > i would like pointers and structures added to euphoria. > pointers are good because you can identify a variable without having to copy > it in This happens automattically, but pointers could be useful is some cases (there are better uses than this):
integer a,b atom c a=~b--a is (internally) a pointer to b(~ here specifies a pointer) --a and b are still undefined a=1 ?b--displays 1 b=2 ?a--displays 2 a=~c--Should cause an error; types must be the same
Unfortunatly, this will probably never be implemented. > memory. you can do that in euphoria but it's much more complicated. structures > are > also possible in euphoria but again not on simple easy way. and structures are > needed > in every program. There are librarys that can do ths easily, there isn't really much to improve. >