Re: Suggestions for ESL (was: Euphoria Standard Library on UBoard)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Juergen Luethje wrote:
> 
> Dave Probert wrote:
> 
> > As far as a naming convention for enum stuff goes, whatever is chosen
> > should reflect what the task is related to.
> >
> > next() is very vague as far as a function name goes,
> 
> Generally speaking, I agree. However I find it tempting to be able to
> write code like (quoting Tommy):
> }}}
<eucode>
> constant
>     DAY_OF_WEEK = enum(),        -- define the enum DAY_OF_WEEK
>     MONDAY  = next(DAY_OF_WEEK), -- MONDAY is the next DAY_OF_WEEK value
>     TUESDAY = next(DAY_OF_WEEK), -- TUESDAY is the next DAY_OF_WEEK value
> ...
> <font color="#330033"></eucode>
{{{
</font>
> 
> > whereas enum_next() would make more sense.
> 
> But
> }}}
<eucode>
> constant
>     DAY_OF_WEEK = enum(),        -- define the enum DAY_OF_WEEK
>     MONDAY  = enum_next(DAY_OF_WEEK),
>     TUESDAY = enum_next(DAY_OF_WEEK),
> ...
> <font color="#330033"></eucode>
{{{
</font>
> doesn't read so nice.
> 
> How about the following:
> }}}
<eucode>
> constant
>     DAY_OF_WEEK = the_enum(),        -- define the enum DAY_OF_WEEK
>     MONDAY  = the_next(DAY_OF_WEEK), -- MONDAY is the next DAY_OF_WEEK value
>     TUESDAY = the_next(DAY_OF_WEEK), -- TUESDAY is the next DAY_OF_WEEK value
> ...
> <font color="#330033"></eucode>
{{{
</font>
> 
> It still reads nice, and because both functions start with 'the_', it's
> (more or less) obvious that they belong together. Or is that too crazy?
> 
> <snip>
> 
> Just an idea,
>    Juergen

Too crazy. :) I don't think that many people would want to put "the_" infront of
anything really.


My $0.02 for if we want to make enum a type:

constant DAYS =  create_enumerator(1),
         SUNDAY = enumerate(DAYS),
         MONDAY = enumerate(DAYS),
         -- etc.

constant MULTIPLES_OF_TEN = create_enumerator({10,   -- start value
                                               10})  -- step value
         TEN = enumerate(MULIPLES_OF_TEN),
         TWENTY = enumerate(MULIPLES_OF_TEN),
         -- etc

It is more work but more descriptive. Kinda like how we use "integer" instead of
"int". We also need to make sure there's a way to specify step value.

The other option is without an explicit enum type.

begin_enumeration({10, 10})
constant TEN = enumerate(),
         TWENTY = enumerate(),
         -- etc.

constant TEN = begin_enumeration({10, 10}),
         TWENTY = enumerate(),
         -- etc.

Again, just throwing ideas around here.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu