[BIOSAL] Random values vs BASE + xyz vs enum for actions

Boisvert, Sebastien boisvert at anl.gov
Wed Nov 5 22:31:29 CST 2014


> From: George K. Thiruvathukal [gkt at cs.luc.edu]
> Sent: Wednesday, November 05, 2014 9:16 PM
> To: Boisvert, Sebastien
> Cc: biosal at lists.cels.anl.gov
> Subject: Re: Random values vs BASE + xyz vs enum for actions
> 
> 
> 
> 
> ​I am potentially ok with this. One thing to consider, however, is that C++ (should we ever go in this direction) enum and int don't play nicely together. Someone might even "wrap" Thorium computations in C++ at some point, which means we will want the code
>  to pass through the C compiler without errors. I'm not sure whether this was intentional, but you also don't have an enum type name in your example.

Yes, it is intentional so that there not an type associated to the listed values. Otherwise, one would need
to put every actions in one single "enum action_type { ACTION_1, ACTION_2, ..., ACTION_N};".


> 
> 
> So I would be careful with enum, because in C, they convert implicitly to/from int. That said, I do like being able to get the auto-increment functionality out of the box. I can be talked into it,

The decision is yours. I like the BASE thing.

> but were I to guess, Andy Tanenbaum did what we did today in
>  Minix for good reasons (possibly still living in his head!)
> 
> 
> Best,
> George
>> 
> 
> 
> George K. Thiruvathukal, PhD
> 
> Professor of Computer Science, Loyola University Chicago
> 
> Director, Center for Textual Studies and Digital Humanities
> Guest Faculty, Argonne National Laboratory, Math and Computer Science Division
> Editor in Chief, Computing in
>  Science and Engineering (IEEE CS/AIP)
> 
> (w) gkt.tv (v)
>  773.829.4872
> 
> 
> 
> 
> 
> 
> 
> On Wed, Nov 5, 2014 at 9:08 PM, Boisvert, Sebastien 
> <boisvert at anl.gov> wrote:
> 
> Hi George,
> 
> The new action definitions that use a base and an offset is great [1].
> 
> #define ACTOR_ACTION_BASE -1000
> 
> #define ACTION_START (ACTOR_ACTION_BASE + 0)
> #define ACTION_START_REPLY (ACTOR_ACTION_BASE + 1)
> #define ACTION_STOP (ACTOR_ACTION_BASE + 2)
> #define ACTION_STOP_REPLY (ACTOR_ACTION_BASE + 3)
> #define ACTION_ASK_TO_STOP (ACTOR_ACTION_BASE + 4)
> #define ACTION_ASK_TO_STOP_REPLY (ACTOR_ACTION_BASE + 5)
> 
> 
> I was told by a friend (from industry) of mine that the following would be better:
> 
> enum {
>     ACTOR_ACTION_BASE = -1000,
>     ACTION_START,
>     ACTION_START_REPLY,
>     ACTION_STOP,
>     ACTION_STOP_REPLY,
>     ACTION_ASK_TO_STOP,
>     ACTION_ASK_TO_STOP_REPLY
> };
> 
> 
> What do you think ?
> 
> 
> ---
> [1] 
> https://github.com/gkthiruvathukal/biosal/commit/8e0448d4c98babd9e471d134745791165fb08536
> 
> 
> 


More information about the BIOSAL mailing list