1. enum suggestion

I wondered if anyone else thought this was a good idea:

enum xx_one, 
     xx_two, 
     xx_max=$ 
?xx_one 
?xx_two 
?xx_max 

should print 1 2 2

Pete

new topic     » topic index » view message » categorize

2. Re: enum suggestion

petelomax said...

I wondered if anyone else thought this was a good idea:

enum xx_one, 
     xx_two, 
     xx_max=$ 
?xx_one 
?xx_two 
?xx_max 

should print 1 2 2

Pete

Something like this has been discussed. I think what we will eventually come up with are various 'properties' of an enum. Something along the lines of ...

enum as xx 
    A = 5, 
    B = 1, 
    C = -1, 
    D = 3 
? xx:A 
? xx:B 
? xx.max 
? xx.min 
? xx.range 
? xx.last 
? xx.first 
? xx.count 

And this should print as 5 1 5 -1 7 3 5 4

However, much more discussion is required before anything further like this will be implemented.

new topic     » goto parent     » topic index » view message » categorize

3. Re: enum suggestion

An interesting version in another language:

enum field as 
name, addr, city, state 

Used as in Euphoria, as a substitute for structures, but also 'reversible', so that field[1] returns 'name'.

This has some uses.

new topic     » goto parent     » topic index » view message » categorize

4. Re: enum suggestion

irv said...

An interesting version in another language:

enum field as 
name, addr, city, state 

Used as in Euphoria, as a substitute for structures, but also 'reversible', so that field[1] returns 'name'.

This has some uses.

Yes, I like that. It should be pretty easy to implement, too.

You'd basically end up with a constant named field, so that your code would be equivalent to:

constant field = {"name", "addr", "city", "state"} 
enum name, addr, city, state 

Although that sort of implementation wouldn't work as well for sparse or non-integral enums.

Matt

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu