D - Associative array strangeness.
- Andy Friesen (4/4) May 04 2003 A char[char[]] is an array of chars, indexed by char[]s, but a
- Burton Radons (3/6) May 04 2003 It would be a bug, but I have code using char[][char[]] successfully
- Andy Friesen (4/14) May 04 2003 ooooookay.
- Sean L. Palmer (19/33) May 04 2003 Maybe it works as:
- Walter (4/19) Jul 15 2003 It works left-to-right, not inside-out as C does. As such, paretheses ar...
A char[char[]] is an array of chars, indexed by char[]s, but a char[][char[]] is, as far as the compiler seems to be concerned, an array of char[][]s, indexed by char[]s. Am I missing something obvious, or is this really weird? :)
May 04 2003
Andy Friesen wrote:A char[char[]] is an array of chars, indexed by char[]s, but a char[][char[]] is, as far as the compiler seems to be concerned, an array of char[][]s, indexed by char[]s.It would be a bug, but I have code using char[][char[]] successfully with the intended meaning. How does the compiler "[seem] to be concerned"?
May 04 2003
Burton Radons wrote:Andy Friesen wrote:ooooookay. I can't reproduce it now, but I was getting a "cannot convert char[][] to char[]" error when trying to extract an element from a char[][char[]].A char[char[]] is an array of chars, indexed by char[]s, but a char[][char[]] is, as far as the compiler seems to be concerned, an array of char[][]s, indexed by char[]s.It would be a bug, but I have code using char[][char[]] successfully with the intended meaning. How does the compiler "[seem] to be concerned"?
May 04 2003
Maybe it works as: (char[])[char[]] x; or char[char[]][] x; or char( x[char[]] )[]; ? C-style typespecs always were confusing. I haven't kept track of how D typespecs improve upon C. It's certainly not readable left-to-right. I assume you're after an associative array mapping strings to strings? alias char[] string; string[string] x; I'm also assuming that D, like C, allows grouping of parts of typespecs by explicit parenthesis. I haven't checked. Walter, care to clarify? Sean "Andy Friesen" <andy ikagames.com> wrote in message news:b943oa$1nh3$1 digitaldaemon.com...Burton Radons wrote:concerned"?Andy Friesen wrote:A char[char[]] is an array of chars, indexed by char[]s, but a char[][char[]] is, as far as the compiler seems to be concerned, an array of char[][]s, indexed by char[]s.It would be a bug, but I have code using char[][char[]] successfully with the intended meaning. How does the compiler "[seem] to beooooookay. I can't reproduce it now, but I was getting a "cannot convert char[][] to char[]" error when trying to extract an element from a char[][char[]].
May 04 2003
"Sean L. Palmer" <palmer.sean verizon.net> wrote in message news:b94ajf$1tdq$1 digitaldaemon.com...Maybe it works as: (char[])[char[]] x; or char[char[]][] x; or char( x[char[]] )[]; ? C-style typespecs always were confusing. I haven't kept track of how D typespecs improve upon C. It's certainly not readable left-to-right. I assume you're after an associative array mapping strings to strings? alias char[] string; string[string] x; I'm also assuming that D, like C, allows grouping of parts of typespecs by explicit parenthesis. I haven't checked. Walter, care to clarify?It works left-to-right, not inside-out as C does. As such, paretheses are not necessary.
Jul 15 2003