From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan McMahill Newsgroups: gmane.lisp.guile.user Subject: Re: passing flags to a function Date: Tue, 02 May 2006 12:21:10 -0400 Message-ID: <445786F6.6030108@mtl.mit.edu> References: <44574FA0.1050108@mtl.mit.edu> <874q08qw42.fsf@laas.fr> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1146587195 18240 80.91.229.2 (2 May 2006 16:26:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 2 May 2006 16:26:35 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue May 02 18:26:33 2006 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Faxhc-0000tg-0M for guile-user@m.gmane.org; Tue, 02 May 2006 18:26:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Faxhb-0003Gd-Ds for guile-user@m.gmane.org; Tue, 02 May 2006 12:26:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FaxhW-0003Fy-NS for guile-user@gnu.org; Tue, 02 May 2006 12:26:14 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FaxhU-0003Dr-K6 for guile-user@gnu.org; Tue, 02 May 2006 12:26:13 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FaxhU-0003De-DT for guile-user@gnu.org; Tue, 02 May 2006 12:26:12 -0400 Original-Received: from [204.127.192.81] (helo=rwcrmhc11.comcast.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Faxhg-0003mB-1L for guile-user@gnu.org; Tue, 02 May 2006 12:26:24 -0400 Original-Received: from [10.0.0.13] (c-24-99-107-156.hsd1.ga.comcast.net[24.99.107.156]) by comcast.net (rwcrmhc11) with ESMTP id <20060502162610m11005g2r3e>; Tue, 2 May 2006 16:26:11 +0000 User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7.6) Gecko/20050412 X-Accept-Language: en-us, en Original-To: =?ISO-8859-1?Q?Ludovic_Court=E8s?= In-Reply-To: <874q08qw42.fsf@laas.fr> X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:5274 Archived-At: Ludovic Courtès wrote: > Hi, > > Dan McMahill 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". > > > What you describe above is doable and is an approach sometimes taken. > See for instance the POSIX functions in Guile, e.g., `popen'. > > Personally, I prefer to pass a list of symbols rather than a single > number in such situations. This might require some more work if you > need to convert those flags to a C or'ed integer, but not so much > because (i) symbols can be compared with `eq' which is fast, (ii) > the list of flags may usually be small, and (iii) the number of values > that can be taken by the flags is small as well. > Hi Ludovic, 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)) I don't care much about speed in this particular case. Thanks -Dan _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user