unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* passing flags to a function
@ 2006-05-02 12:25 Dan McMahill
  2006-05-02 15:34 ` Ludovic Courtès
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Dan McMahill @ 2006-05-02 12:25 UTC (permalink / raw)


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


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-05-07 21:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-02 12:25 passing flags to a function Dan McMahill
2006-05-02 15:34 ` Ludovic Courtès
2006-05-02 16:21   ` Dan McMahill
2006-05-02 16:55     ` Ludovic Courtès
2006-05-02 16:56       ` Dan McMahill
2006-05-07 21:03     ` Marius Vollmer
2006-05-02 16:14 ` Clinton Ebadi
2006-05-03  1:43 ` Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).