POV-Ray : Newsgroups : povray.programming : enum { SOMETHING = 'Thing' } ? Server Time
3 Jul 2024 05:47:03 EDT (-0400)
  enum { SOMETHING = 'Thing' } ? (Message 4 to 13 of 13)  
<<< Previous 3 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 2 Feb 2004 05:52:23
Message: <401e2be7@news.povray.org>
AngleWyrm <no_### [at] hotmailcom> wrote:
>  kPOVMsgClass_RenderControl   = 'Ctrl',

> 'Ctrl' is quite a bit different from what I'm used to using for enumeration,
> and also looks a bit like a four-byte char?

  'Ctrl' is the value 1131704940.

  (If you can't deduce why, I can explain that as well.)

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: AngleWyrm
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 02:14:21
Message: <4021ed4d$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:401e2be7@news.povray.org...
> AngleWyrm <no_### [at] hotmailcom> wrote:
> >  kPOVMsgClass_RenderControl   = 'Ctrl',

>   'Ctrl' is the value 1131704940.
>   (If you can't deduce why, I can explain that as well.)

'C'<<32|'t'<<16|'r'<<8|'l'

What I can't deduce is where/how the value of the enum is used.
I've seen some lines using if(cur->handledclass == hclass) type statements,
but this is just normal enum handling.


Post a reply to this message

From: AngleWyrm
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 02:28:51
Message: <4021f0b3$1@news.povray.org>
"ABX" <abx### [at] abxartpl> wrote in message
news:t58s1015437i6sh8q0jv9m16sm6eomafna@4ax.com...
> On Sat, 31 Jan 2004 12:42:19 -0800, "AngleWyrm"
> <no_### [at] hotmailcom> wrote:
> > 'Ctrl' is quite a bit different from what I'm used to using for
enumeration,
> > and also looks a bit like a four-byte char?
>
> 'Ctrl' is alternative notation for 32-bit integers here.

So this would be saying the same thing sleightly differently:

#define CTRL 1131704940
enum { kPOVMsgClass_RenderControl   = CTRL }

Is this numerical encoding used as an error catching mechanism during code
construction? I haven't been able to find further references to 'Ctrl'
outside the enum declaration.


Post a reply to this message

From: ABX
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 02:47:31
Message: <60t320p8r7lpgepjg2nplk9ptkkgskioq9@4ax.com>
On Wed, 4 Feb 2004 23:21:28 -0800, "AngleWyrm" <no_### [at] hotmailcom>
wrote:
> Is this numerical encoding used as an error catching mechanism during code
> construction? I haven't been able to find further references to 'Ctrl'
> outside the enum declaration.

Are you looking references to 'Ctrl' or to kPOVMsgClass_RenderControl?

ABX


Post a reply to this message

From: AngleWyrm
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 06:12:35
Message: <40222523@news.povray.org>
"ABX" <abx### [at] abxartpl> wrote in message
news:60t320p8r7lpgepjg2nplk9ptkkgskioq9@4ax.com...
> On Wed, 4 Feb 2004 23:21:28 -0800, "AngleWyrm"
<no_### [at] hotmailcom>
> wrote:
> > Is this numerical encoding used as an error catching mechanism during
code
> > construction? I haven't been able to find further references to 'Ctrl'
> > outside the enum declaration.
>
> Are you looking references to 'Ctrl' or to kPOVMsgClass_RenderControl?

'Ctrl'

If the enums were given specific values, it was my guess that at some point
in the program a comparison to, or usage of those specific values would take
place. Makes sense?

Thus I surmized that there must be more than one occurance of the term 'Ctl'
within the source files, so I went looking for this. I only found the one
occurance, and this got me wondering if it was an exception to a norm. Hey
maybe the rest of them or even just some of them are used in some
comparison.

So I did a grep search on '\(....\)' to find all single quoted four-letter
blocks. The only code (besides comments) that came back were the
enumerations themselves. (www.textpad.com, nice notepad replacement)

Thus far, it seems that my guess may be in error; perhaps those values
aren't used anywhere else?


Post a reply to this message

From: AngleWyrm
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 07:02:58
Message: <402230f2$1@news.povray.org>
Some possible reasons:
* It may have applied to old code that is no longer a part of the program

* It may have applied to an old plan that was never implemented

* It may have been a method of creating a 'sparse' enum set, to avoid
accidentally refererencing with the wrong kind--But there's a better ways to
catch that mishap:

enum animals {CAT, DOG, MOUSE};
enum colors {RED,GREEN,BLUE};
void MyAnimalFunc( animals eInput ){}; // enum type specified
int main(void)
  MyAnimalFunc( CAT ); // works fine
  MyAnimalFunc( RED ); // compiler gets it: cannot convert 'colors' to
'animals'
}

* It might apply to tools/utilities that reside outside the program

* I've overlooked something totally obvious, and should go get another cup
of coffee


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 07:54:07
Message: <40223cef$1@news.povray.org>
In article <40222523@news.povray.org> , "AngleWyrm" 
<no_### [at] hotmailcom> wrote:

> If the enums were given specific values, it was my guess that at some point
> in the program a comparison to, or usage of those specific values would take
> place. Makes sense?

No, nobody would define enums and then not use them.  Enums are given
"names" because those mean more to a human when debugging.  Otherwise you
would always have to manually count which value you are currently dealing
with, which is insane if you are dealing with more than just a handful of
value.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 07:59:11
Message: <40223e1f@news.povray.org>
In article <402230f2$1@news.povray.org> , "AngleWyrm" 
<no_### [at] hotmailcom> wrote:

> * I've overlooked something totally obvious, and should go get another cup
> of coffee

Bingo! ;-)  If you want to create programs that can exchange data including
enumerations, you absolutely have to assign each enumeration a distinct
value.  Otherwise all programs would have to be updated each time
enumeration value if added or removed.  The one kind of value that is on the
one hand easy to read when debugging, and on the other hand will result in a
fairly unique enumeration value is a four character constant.  That is also
why you find them used in many operating system programming interfaces.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: AngleWyrm
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 6 Feb 2004 04:56:11
Message: <402364bb$1@news.povray.org>
"Thorsten Froehlich" <tho### [at] trfde> wrote in message
news:40223cef$1@news.povray.org...
> In article <40222523@news.povray.org> , "AngleWyrm"
> <no_### [at] hotmailcom> wrote:
>
> > If the enums were given specific values,
>> it was my guess that at some point in the program
>> a comparison to, or usage of those specific values would take place.
>> Makes sense?

> No, nobody would define enums and then not use them.
Have you seen these enum values used somewhere?
This is what I have gone looking, and haven't found them used anywhere.

> Enums are given "names" because those mean more to a human when debugging.
Doesn't your debugger display enums directly?
enum CRITTERS {CAT, DOG, MOUSE};
CRITTERS animal = CAT;
debugger says:" animal = CAT " which is plenty clear enough.
And this works for any external program that uses the header file in which
the enum is defined.

What is gained by saying the variable 'animal', which has a value of CAT,
also has a numerical value that can be translated to 'cat'?


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 6 Feb 2004 08:13:45
Message: <40239309@news.povray.org>
In article <402364bb$1@news.povray.org> , "AngleWyrm" 
<no_### [at] hotmailcom> wrote:

>> No, nobody would define enums and then not use them.
>
> Have you seen these enum values used somewhere?
> This is what I have gone looking, and haven't found them used anywhere.

Well, as has been pointed out, you have to search for the enum names, not
their values.  As they are used by POVMS messages, look into the code
sending and receiving POVMS messages.

>> Enums are given "names" because those mean more to a human when debugging.
>
> Doesn't your debugger display enums directly?

Most high-level debbuggers do display enums directly, yes.  However,
low-level debuggers don't, and neither do queue/network loggers.  Thus, if
doing IPC, you quickly learn to appreciate being able to read what is going
on.

> enum CRITTERS {CAT, DOG, MOUSE};
> CRITTERS animal = CAT;
> debugger says:" animal = CAT " which is plenty clear enough.
> And this works for any external program that uses the header file in which
> the enum is defined.

Yes, but is does not work well if you ever want to *extend* the enum.  You
quickly end up with hard to find bugs or having to recompile all external
programs every time some extension is made, even if that extension is not
used by the external program at all.

> What is gained by saying the variable 'animal', which has a value of CAT,
> also has a numerical value that can be translated to 'cat'?

See what I outlined above.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

<<< Previous 3 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.