From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Panicz Maciej Godek Newsgroups: gmane.lisp.guile.user Subject: Re: ?-suffix for booleans... good-idea? or bad-idea? Date: Thu, 27 Apr 2017 12:53:37 +0200 Message-ID: References: <878tmpoi3x.fsf@dustycloud.org> <87a872xhg1.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1493290473 19059 195.159.176.226 (27 Apr 2017 10:54:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 27 Apr 2017 10:54:33 +0000 (UTC) Cc: "guile-user@gnu.org" To: Jan Nieuwenhuizen Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Apr 27 12:54:28 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 1d3h3s-0004K9-3e for guile-user@m.gmane.org; Thu, 27 Apr 2017 12:54:12 +0200 Original-Received: from localhost ([::1]:59933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3h3x-0005kD-Sy for guile-user@m.gmane.org; Thu, 27 Apr 2017 06:54:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3h3P-0005hs-1I for guile-user@gnu.org; Thu, 27 Apr 2017 06:53:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3h3O-0001Hl-1d for guile-user@gnu.org; Thu, 27 Apr 2017 06:53:43 -0400 Original-Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:36996) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d3h3L-0001Gi-Rn; Thu, 27 Apr 2017 06:53:40 -0400 Original-Received: by mail-wm0-x22b.google.com with SMTP id m123so14492892wma.0; Thu, 27 Apr 2017 03:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=p3uN/jZc9rqPtFezF0J+RhvT6yKmAYOAundmgZidY3A=; b=t4fCpIFXybrno9NtIvQM6w1VjdOK+CYUvi45Sw4uApkjt7MLb+z2Ky7ozX1BL96te2 eVO5zMnlPni83bj8P0z9DMuO+68H59yQsZIfEFok93owul8aYv9FqV7abROdBYopvBDe EPQxaSJZd6SzJUuCh2RWuS9Gz6dw+kT4IabwsrttErkVEFkDAvS9PmigyAenQYCpsgP/ ZKjY77DNTu+LvJ9Gaf6FUBpSi07rkHb44i+VtTL6gsjArGBu92oxOxGme4wvGWJbBsG1 flsJ0fbufzzXU0d2NYyYMqwrcwjFl7q+7DfgD1vfCfln8T9YpuhPPo8IeW3nbea/qM55 lkTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=p3uN/jZc9rqPtFezF0J+RhvT6yKmAYOAundmgZidY3A=; b=UDp5L6fQnnJGV0pixmzpmI5bt0HboFjQ4vPwkHcPq0Rp33mlfDn2uledZNCGxoHyaX Tvq2yxzwboRiartFkPxp6R7h6ngesTxf+Qsej9W2BofaYQx1I5btU5v3Lpiq9t0adBF6 FtxFQSyftO7RBNz/syJYQQrg9Mo55ingmkxGGnCEiJJkXHh1jyf8cILKXjQd5b4HSFwN 0Bm6FNTNIlysHf806GihDk7mAJgGJ+7pyfM5Gmi331vA2qgT6uQUHh17GWsgOXI2omXP B6y63QM2uB/lADz6CsuJ3zrFA2yPROPDoKiMuvP5p5bf/2HOlaKSN/Phcf0JOpN16Y3N uLwg== X-Gm-Message-State: AN3rC/6My3qy3wW0CqyiqEzt6kj/XsP444hp3ZA062E91NDfyq+FZU0N gWWUS50ZCqesigEYiWq73Mxz28xEEvwn1t8= X-Received: by 10.80.179.24 with SMTP id q24mr4099979edd.27.1493290418221; Thu, 27 Apr 2017 03:53:38 -0700 (PDT) Original-Received: by 10.80.138.150 with HTTP; Thu, 27 Apr 2017 03:53:37 -0700 (PDT) In-Reply-To: <87a872xhg1.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22b X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:13642 Archived-At: 2017-04-27 12:39 GMT+02:00 Jan Nieuwenhuizen : > Christopher Allan Webber writes: > > > I've noticed that it's common in Guile modules to use "foo?" for > > variable names involving booleans. It's tempting, > > > But is it a good idea? > > It's an idea that I like and use. Not sure that says anything about > good or bad. > > I would like to help you paint though! > > We have functions like null? and pair? that return booleans, where I > would like the [non]-nil value. I often find myself writing things like > > (let ((bar (if (pair? foo) (baz foo) > #f))) > > where I would rather like to write something like > > (let ((bar (and=> (pair?=> foo) baz))) > > How do you do these things, and how do you call your pair?=> function? > > I usually use the and-let* form (SRFI-2) to deal with such cases. (and-let* (((pair? foo))) (baz foo)) The (grand scheme) library which I maintain provides a variant of and-let* that additionally provides pattern matching: https://github.com/plande/grand-scheme/blob/master/grand/syntax.scm#L255 so you could even write the above code as (and-let* (((_ . _) foo)) (baz foo))