digitalmars.D - <newbie>"null is not an lvalue"
- Asaf Karagila (10/10) Dec 11 2004 Hi,
- Asaf Karagila (6/17) Dec 11 2004 i feel so stupid :)
- Sjoerd van Leent (11/39) Dec 11 2004 I don't understand the reason why you want a constant associative array,...
- Sjoerd van Leent (6/50) Dec 11 2004 Correction:
-
Simon Buchan
(23/26)
Dec 15 2004
Hi, i was trying to initialize a list of strings (related to my previous post about assembling bytecode) into an associative array, i got the following error message "null is not an lvalue" the array declaration is const ubyte[char[]] mnemonics; this is an example for one of the lines i used to initialize the array: mnemonics["EXIT"]=cast(ubyte)0xFF; any ideas ? - Asaf.
Dec 11 2004
i feel so stupid :) i forgot to remove the const from the array declaration when i changed it to an associative array.. - Asaf. "Asaf Karagila" <kas1 netvision.net.il> wrote in message news:cpeolu$1vjf$1 digitaldaemon.com...Hi, i was trying to initialize a list of strings (related to my previous post about assembling bytecode) into an associative array, i got the following error message "null is not an lvalue" the array declaration is const ubyte[char[]] mnemonics; this is an example for one of the lines i used to initialize the array: mnemonics["EXIT"]=cast(ubyte)0xFF; any ideas ? - Asaf.
Dec 11 2004
I don't understand the reason why you want a constant associative array, because this easy solvable using an enumeration and a normal array, just as the following: /*CODE*/ public enum Codes {Exit}; public const static ubyte map[] = [0xff : Codes.Exit]; /*END_CODE*/ You are able to select the right values using the Codes enumeration. Regards, Sjoerd Asaf Karagila wrote:i feel so stupid :) i forgot to remove the const from the array declaration when i changed it to an associative array.. - Asaf. "Asaf Karagila" <kas1 netvision.net.il> wrote in message news:cpeolu$1vjf$1 digitaldaemon.com...Hi, i was trying to initialize a list of strings (related to my previous post about assembling bytecode) into an associative array, i got the following error message "null is not an lvalue" the array declaration is const ubyte[char[]] mnemonics; this is an example for one of the lines i used to initialize the array: mnemonics["EXIT"]=cast(ubyte)0xFF; any ideas ? - Asaf.
Dec 11 2004
Correction: public enum Codes {Exit = 0xff}; This is sufficient. Regards, Sjoerd Sjoerd van Leent wrote:I don't understand the reason why you want a constant associative array, because this easy solvable using an enumeration and a normal array, just as the following: /*CODE*/ public enum Codes {Exit}; public const static ubyte map[] = [0xff : Codes.Exit]; /*END_CODE*/ You are able to select the right values using the Codes enumeration. Regards, Sjoerd Asaf Karagila wrote:i feel so stupid :) i forgot to remove the const from the array declaration when i changed it to an associative array.. - Asaf. "Asaf Karagila" <kas1 netvision.net.il> wrote in message news:cpeolu$1vjf$1 digitaldaemon.com...Hi, i was trying to initialize a list of strings (related to my previous post about assembling bytecode) into an associative array, i got the following error message "null is not an lvalue" the array declaration is const ubyte[char[]] mnemonics; this is an example for one of the lines i used to initialize the array: mnemonics["EXIT"]=cast(ubyte)0xFF; any ideas ? - Asaf.
Dec 11 2004
On Sat, 11 Dec 2004 16:05:23 +0100, Sjoerd van Leent <svanleent wanadoo.nl> wrote:Correction: public enum Codes {Exit = 0xff}; This is sufficient.<snip> Except he probably wants to be reading strings. An AA is the easiest way to do that by far. Doing this with a Key Value pair array is the only way I can think of doing this without an AA involved. struct code {char[] name; ubyte value}; const code[] codemap = {{"EXIT", 0xFF}, {"SOMETHING ELSE", 0x3E}}; -- "Unhappy Microsoft customers have a funny way of becoming Linux, Salesforce.com and Oracle customers." - www.microsoft-watch.com: "The Year in Review: Microsoft Opens Up" -- "I plan on at least one critical patch every month, and I haven't been disappointed." - Adam Hansen, manager of security at Sonnenschein Nath & Rosenthal LLP (Quote from http://www.eweek.com/article2/0,1759,1736104,00.asp) -- "It's been a challenge to "reteach or retrain" Web users to pay for content, said Pizey" -Wired website: "The Incredible Shrinking Comic"
Dec 15 2004