Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 04, 2003 Associative array strangeness. | ||||
---|---|---|---|---|
| ||||
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 Re: Associative array strangeness. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | 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 Re: Associative array strangeness. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | Burton Radons wrote:
> 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"?
>
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[]].
|
May 05, 2003 Re: Associative array strangeness. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | 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: > > 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"? > > > > 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[]]. |
July 15, 2003 Re: Associative array strangeness. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "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. |
Copyright © 1999-2021 by the D Language Foundation