www.digitalmars.com         C & C++   DMDScript  

D - Rectangular Arrays, setting

reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
With one-dimensional arrays, you use a trailing [] to indicate that you
want to assign by value (i.e. copy from the original array), while you
leave it off to copy by reference (i.e. point the new array into the old
one).  How do you do this by with rectangular arrays?  With a
2-dimensional array, I could see 3 possible things that the programmer
might desire:

* point the new array directly into the old
* Don't copy the data elements, but make new array elements in the new
array that point into the old data
* Copy the data.

Which is the correct syntax for each?  (And let's put this into the
Specification, unless it's already there and I've just missed it.)

--
The Villagers are Online! villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]
Feb 18 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3C711C80.C96995E7 deming-os.org...

 With one-dimensional arrays, you use a trailing [] to indicate that you
 want to assign by value (i.e. copy from the original array), while you
 leave it off to copy by reference (i.e. point the new array into the old
 one).  How do you do this by with rectangular arrays?  With a
 2-dimensional array, I could see 3 possible things that the programmer
 might desire:

 * point the new array directly into the old

This is as simple as a = b;
 * Don't copy the data elements, but make new array elements in the new
 array that point into the old data

 * Copy the data.

Don't forget that there's no such thing as rectangular dynamic array. Either you have a dynamic array of arrays - in which case the []= op would copy the subarrays (that is, pointers), or you have a static rectangular array, and []= should copy its contents: int[2][3] foo, bar; foo[] = bar[]; // copy the entire rectangular array int[][] foo, bar; foo[] = bar[]; // copy all int[] elements from foo to bat
Feb 18 2002
parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Pavel Minayev wrote:

 * Copy the data.

Don't forget that there's no such thing as rectangular dynamic array. Either you have a dynamic array of arrays - in which case the []= op would copy the subarrays (that is, pointers), or you have a static rectangular array, and []= should copy its contents: int[2][3] foo, bar; foo[] = bar[]; // copy the entire rectangular array int[][] foo, bar; foo[] = bar[]; // copy all int[] elements from foo to bat

It will take me a bit to get my mind around this...dynamic arrays are really cool...but still a new paradigm for me. I'll write back if I have any more ponders. -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
Feb 18 2002
parent reply "OddesE" <OddesE_XYZ hotmail.com> writes:
<SNIP>
 --
 The Villagers are Online! villagersonline.com

 .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
 .[ (a version.of(English).(precise.more)) is(possible) ]
 ?[ you want.to(help(develop(it))) ]

Sorry for going totally offtopic here, but what does the above text mean? :) I have been wondering about your signature since I first saw it Russ, I also visited villagersonline.com but I didn't see anything to explain it...This is killing me! :) Also, the picture of the man with the glasses on the Hosea page, http://villagersonline.com/hoseaProject/ is that you? Regards, -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail
Feb 19 2002
parent Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
OddesE wrote:

 .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
 .[ (a version.of(English).(precise.more)) is(possible) ]
 ?[ you want.to(help(develop(it))) ]

Sorry for going totally offtopic here, but what does the above text mean? :)

I've had this sig (or things like it) for probably something like 2 years and this is the first time anybody's asked me about those 3 lines. www.villagersonline.com is the website for my church - I'm the webslave there. The other three lines are totally unrelated (to the church). It's my attempt at a C-style way of writing English. Essentially, each expression (marked of with square brackets) is comprised of at least a subject and verb section. Modifiers to clauses, phrases, or words follow it with .'s to mark them off, like properties or member functions. Thus, the three lines are the translation of: The quick brown fox jumped over the lazy dog. A more precise version of English is possible. Do you want to help develop it?
 I have been wondering about your signature since I
 first saw it Russ, I also visited villagersonline.com but
 I didn't see anything to explain it...This is killing me!  :)
 Also, the picture of the man with the glasses on the
 Hosea page, http://villagersonline.com/hoseaProject/
 is that you?

LOL! No, that's Rod (about 30 years my senior). I'm the guy on the bottom left at http://villagersonline.com/sermons (webmaster villagersonline.com) -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
Feb 19 2002