From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: ?-suffix for booleans... good-idea? or bad-idea? Date: Tue, 25 Apr 2017 19:08:33 +0100 Message-ID: References: <878tmpoi3x.fsf@dustycloud.org> <87inltgnj8.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1493143747 15315 195.159.176.226 (25 Apr 2017 18:09:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 25 Apr 2017 18:09:07 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Apr 25 20:09:03 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d34ta-0003rS-Pz for guile-user@m.gmane.org; Tue, 25 Apr 2017 20:09:02 +0200 Original-Received: from localhost ([::1]:50762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d34te-00087I-Uu for guile-user@m.gmane.org; Tue, 25 Apr 2017 14:09:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d34tI-00087D-E8 for guile-user@gnu.org; Tue, 25 Apr 2017 14:08:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d34tD-0002CP-D5 for guile-user@gnu.org; Tue, 25 Apr 2017 14:08:44 -0400 Original-Received: from smtp-out-1.talktalk.net ([62.24.135.65]:58299) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d34tD-0002BF-65 for guile-user@gnu.org; Tue, 25 Apr 2017 14:08:39 -0400 Original-Received: from arudy.520b.com ([2.96.192.194]) by smtp.talktalk.net with SMTP id 34t8dEvqW9tMz34t8dF7pt; Tue, 25 Apr 2017 19:08:36 +0100 X-Originating-IP: [2.96.192.194] X-Spam: 0 X-OAuthority: v=2.2 cv=WOE9ZTkR c=1 sm=1 tr=0 a=L9r2or1llNJpkmWEAwxYbQ==:117 a=L9r2or1llNJpkmWEAwxYbQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=AzvcPWV-tVgA:10 a=Xa_x4tXAAAAA:8 a=ldY53ym4U1T3UgT9fWYA:9 a=pILNOxqGKmIA:10 a=3fPbONZQSPE9vWV_L8Lq:22 Original-Received: from [192.168.1.13] (unknown [192.168.1.13]) by arudy.520b.com (Postfix) with ESMTPSA id 4F24A38012 for ; Tue, 25 Apr 2017 19:00:23 +0100 (BST) In-Reply-To: <87inltgnj8.fsf@gmail.com> X-CMAE-Envelope: MS4wfPvWmmiYq1r1DAEFm4Z8w/461+uWTOehAcTkPx0Yau6WfTuuvq5/EYhxY5gD8FnevnitRL0p4YA3juCElWqAPaHvsCazv0yep3W12z7NIRZ7R2vyZozD 7YSGY0fUB5nNPrWRJot/ZF5rV13KERx+fzOZswWTzZtzg0gSTvKrdghA X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 62.24.135.65 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13630 Archived-At: I'm also not sure. In the past I've written code with an 'xxx?' variable, and then added a procedure to set it, giving 'set-xxx?!' - which is not exactly elegant. Also I'm not sure it's best practice to have many variables/attributes/parameters with boolean values, as this can lead to code that has too many opaque uses of #t and #f. (I.e. it's often unclear, at the point of use, what each #t or #f means.) It might be better to refactor to something with non-boolean values, e.g. from (set! red? #t) (set! narrow?#t) to (set! properties '(red narrow)) And in that case the question about '?' would disappear. Regards, Neil On 25/04/17 04:43, Alex Vong wrote: > Good question! I can't decide as well. I want to know how people think > about it. > > In a lazy language, a variable is a 0-ary thunk, while a predicate is a > 1-ary thunk. Since they are really just special case of a general thing, > it make sense to use foo? for both cases. But we all know guile is not > lazy, so I really don't know what to do. > > Christopher Allan Webber writes: > >> Hello everyone! Here's a little bikeshed for us to paint. >> >> I've noticed that it's common in Guile modules to use "foo?" for >> variable names involving booleans. It's tempting, because this looks >> an awful lot like you're asking a question... and it's also common >> for this even to be keyword arguments to procedures, etc. >> >> But is it a good idea? I thought "foo?" was supposed to be for >> predicates, as a nicer version of the "foo-p" predicate convention in >> other non-scheme lisps. I can't imagine other lisps doing "foo-p" for >> just variables with boolean values. >> >> On the other hand, once you start adding ? to the end of boolean'y >> things, it *does* become tempting to put them at the end of boolean >> variables and arguments. It looks pretty nice. >> >> What do people think? I'm struggling with deciding what's the right >> thing for my own code, but leaning towards "we shouldn't use the ? >> suffix for just boolean values". >> >> - Chris