forum-msg-id-124765-edit

Original date:2014-07-02 16:29:37 Edited by: petelomax Subject: Re: Suggestion: declaring multiple interleaved constant sequences

I'm not sure I follow, well actually I am sure that I don't follow.

I (on Phix) can now happily do this:

function rgb(integer r, integer g, integer b) 
        return r + g * 256 + b * 65536 
end function 
 
constant Black          = rgb(#00, #00, #00), 
         NavyBlue       = rgb(#00, #00, #60), 
         Blue           = rgb(#00, #00, #80), 
         BrightBlue     = rgb(#00, #00, #FF) 
 
constant {w32ColorNames,w32ColorValues} = columnize({{"Black",Black}, 
                                                     {"NavyBlue",NavyBlue}, 
                                                     {"Blue",Blue}, 
                                                     {"BrightBlue",BrightBlue}}) 
 
for i=1 to length(w32ColorNames) do 
    printf(1,"Color %s Value %08x\n",{w32ColorNames[i],w32ColorValues[i]}) 
end for 

And there is no problem whatsoever with Blue/Black/etc being an enum.

You seem to be suggesting that I should be able to do this (yuk):

constant {w32ColorNames,w32ColorValues} = columnize({{"Black",constant Black=rgb(#00, #00, #00)}, 
                                                     {"NavyBlue",constant NavyBlue= rgb(#00, #00, #60)}, 
                                                     {"Blue",constant Blue= rgb(#00, #00, #80)}, 
                                                     {"BrightBlue",constant BrightBlue= rgb(#00, #00, #FF)}}) 

or even worse:

constant {w32ColorNames,w32ColorValues} = columnize({{"Black",      |enum   Black,|}, 
                                                     {"NavyBlue",   |       NavyBlue,|}, 
                                                     {"Blue",       |       Blue,|}, 
                                                     {"BrightBlue", |       BrightBlue|}}) 

Confused,
Pete

Edit: Sorry, I also had this strange "construct" in mind:

constant {w32ColorNames,@={w32ColorValues,{Black,           |= columnize({{"Black",      rgb(#00, #00, #00)}, 
                                           NavyBlue,        |             {"NavyBlue",   rgb(#00, #00, #60)}, 
                                           Blue,            |             {"Blue",       rgb(#00, #00, #80)}, 
                                           BrightBlue}}}    |             {"BrightBlue", rgb(#00, #00, #FF)}}) 

not that I'm suggesting that is doable or desireable.

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu