[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
passing flags to a function
From: |
Dan McMahill |
Subject: |
passing flags to a function |
Date: |
Tue, 02 May 2006 08:25:04 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7.6) Gecko/20050412 |
Hello,
I'm sure this is a very basic question about passing "or-able" flags to
a function. In C I might do something like:
#define FLAG_FOO 1
#define FLAG_BAR 2
#define FLAG_BAZ 4
....
myfn(int flags)
{
if (flags & FLAG_BAR)
printf ("bar flag is set\n");
...
}
and then call myfn with things like
myfn(FLAG_FOO | FLAG_BAZ);
now suppose I want to wrap up myfn and make it available from scheme.
What is the normal scheme way for passing in flags to a function?
I can do something like
SCM scm_myfn(SCM flags)
{
myfn (scm_num2int (flags, SCM_ARG1, "myfn"));
return SCM_BOOLEAN_T;
}
but I'm not sure of the best way to define the flags in scheme. Or
maybe this is not "the scheme way".
Thanks for any suggestions.
-Dan