Re: passing flags to a function

2006-05-07 Thread Marius Vollmer
Dan McMahill <[EMAIL PROTECTED]> writes: > Are you meaning > > (foo (list 'flag1 'flag2 'someotherflag)) To make this look nicer, you can also write (foo '(flag1 flag2 someotherflag)) Another option are keyword arguments, like (foo :flag1 #t :flag2 #t :someotherflag #t) There is no C

Re: passing flags to a function

2006-05-02 Thread Kevin Ryde
Dan McMahill <[EMAIL PROTECTED]> writes: > > SCM scm_myfn(SCM flags) > { > myfn (scm_num2int (flags, SCM_ARG1, "myfn")); Various things in the guile core are done like that, stuff like O_RDWR for `open'. The list of symbols Ludovic described is done in the guile-gtk interface and works nicely t

Re: passing flags to a function

2006-05-02 Thread Dan McMahill
Ludovic Courtès wrote: Hi, Dan McMahill <[EMAIL PROTECTED]> writes: Thanks for the reply. Could you show a short example of what the scheme function call might look like? Are you meaning (foo (list 'flag1 'flag2 'someotherflag)) Rather, it would look like: (foo 'flag1 'flag2 'someothe

Re: passing flags to a function

2006-05-02 Thread Ludovic Courtès
Hi, Dan McMahill <[EMAIL PROTECTED]> writes: > Thanks for the reply. Could you show a short example of what the > scheme function call might look like? > > Are you meaning > > (foo (list 'flag1 'flag2 'someotherflag)) Rather, it would look like: (foo 'flag1 'flag2 'someotherflag) This is bec

Re: passing flags to a function

2006-05-02 Thread Dan McMahill
Ludovic Courtès wrote: Hi, Dan McMahill <[EMAIL PROTECTED]> writes: 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

Re: passing flags to a function

2006-05-02 Thread Clinton Ebadi
On Tue, 2006-05-02 at 08:25 -0400, Dan McMahill wrote: > 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: ...snip... You can make the flags available to scheme as numbers, and then the Scheme users can use Guile's b

Re: passing flags to a function

2006-05-02 Thread Ludovic Courtès
Hi, Dan McMahill <[EMAIL PROTECTED]> writes: > 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"

passing flags to a function

2006-05-02 Thread Dan McMahill
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