Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Enhanced enumerations

3 views
Skip to first unread message

Jonathan Lang

unread,
Mar 19, 2007, 5:31:23 PM3/19/07
to p6l
Some (many?) enumerations represent cycles, where incrementing from
the last element takes you back to the first: the seasons, the months,
the days of the week, the hues, etc. How hard would it be to write a
module that lets you say something like:

enum weekdays is cycle <Sun Mon Tue Wed Thu Fri Sat>

So that Sat++ eqv Sun (and a resumable control exception is thrown so
that you can do something fancy whenever you return to the start of
the cycle)?


Likewise, how would one be able to legally say:

enum seasons <spring summer autumn|fall winter>

That is, to use a junction in the definition in order to provide
synonyms for one of the enumerated values?

--
Jonathan "Dataweaver" Lang

Andy Armstrong

unread,
Mar 19, 2007, 6:30:22 PM3/19/07
to Jonathan Lang, p6l
On 19 Mar 2007, at 21:31, Jonathan Lang wrote:

> Some (many?) enumerations represent cycles, where incrementing from
> the last element takes you back to the first: the seasons, the months,
> the days of the week, the hues, etc. How hard would it be to write a
> module that lets you say something like:
>
> enum weekdays is cycle <Sun Mon Tue Wed Thu Fri Sat>
>
> So that Sat++ eqv Sun (and a resumable control exception is thrown so
> that you can do something fancy whenever you return to the start of
> the cycle)?

Another way of looking at that enum is as a simple state machine.
More complex state machines would be nice too. That is all :)

--
Andy Armstrong, hexten.net

0 new messages