Re: Namespace Proposal
- Posted by Tone Skoda <tone.skoda at siol.net> Jun 23, 2001
- 433 views
What's with structures? I would like to see them in Euphoria someday. Language is good if code explains itself (if no comments needed). structure COLOR integer red integer green integer blue end structure COLOR color color.red = 255 color.green = 0 color.blue = 0 ? color.red ? color.blue ? color.green --- In current version of Euphoria, closest I can get to structures is like this: constant COLOR_RED = 1 constant COLOR_GREEN = 2 constant COLOR_BLUE = 3 -- Here I describe my structure: -- 1. integer red -- 2. integer green -- 3. integer blue type COLOR (sequence s) if length (s) != 3 then return false end if if not integer (s [COLOR_RED]) then return false end if if not integer (s [COLOR_GREEN]) then return false end if if not integer (s [COLOR_BLUE]) then return false end if return true end type COLOR color color = {255, 0, 0} ? color [COLOR_RED] ? color [COLOR_GREEN] ? color [COLOR_BLUE]