I'm curious what the current best practice is for handling 'enum'-like scenarios.
For my contrived example, I have an ORDER-FOOD function where you pick your dish, and that dish comes with onions.
order: func [ 'dish [word!] /sub 'veggie [word!] ][ ... ]
You can substitute onions for one other vegetable, but obviously I only have so many vegetables at a given time, so I'd like to be sure that you either get onions or another available vegetable.
order enchiladas order/sub burrito mushrooms
First thought is using
veggie: default ['onions]
That's fine so long as I have what the given vegetable is. What if I only have
[onions zucchini artichoke carrot]?
There is the FIND approach:
if not find veggie-box veggie [ veggie: onions ]
Then again, I'm always mindful of CSS's: if it doesn't exist, ignore it. This approach has allowed CSS to adapt as new methodologies exist. How
display that has been around for as long as I can recall gains a
grid value that permits all kinds of heretofore layout possibilities. Any browser out there that doesn't know what
grid means will happily display content as if it was whatever the call to
grid replaced. Similarly, all the properties associated with grid layout are just ignored by older browsers.
Not quite sure how that maps to my function, but it'd be interesting to say:
any [ order/sub bibimbap bok-choy order/sub bibimbap carrot order burger ]
In the event of its availability one day, that I may have that fresh crunchy cabbage.