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: Tue, 25 Apr 2017 18:53:44 +0200 Message-ID: References: <878tmpoi3x.fsf@dustycloud.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1493139251 30973 195.159.176.226 (25 Apr 2017 16:54:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 25 Apr 2017 16:54:11 +0000 (UTC) Cc: "guile-user@gnu.org" To: Christopher Allan Webber Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Apr 25 18:54:07 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 1d33j3-0007us-7S for guile-user@m.gmane.org; Tue, 25 Apr 2017 18:54:05 +0200 Original-Received: from localhost ([::1]:50516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d33j8-0001s2-Vf for guile-user@m.gmane.org; Tue, 25 Apr 2017 12:54:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d33il-0001rl-Rd for guile-user@gnu.org; Tue, 25 Apr 2017 12:53:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d33ik-0002YA-IC for guile-user@gnu.org; Tue, 25 Apr 2017 12:53:47 -0400 Original-Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:38255) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d33ik-0002X5-8K for guile-user@gnu.org; Tue, 25 Apr 2017 12:53:46 -0400 Original-Received: by mail-wm0-x22b.google.com with SMTP id r190so102303638wme.1 for ; Tue, 25 Apr 2017 09:53:45 -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=OYgqExrd4EXuuO1D6Ww0Q1CdWXTOsm/RjoYQacjMg4g=; b=BXVMC9vVySPVAzBwvBJ8ceFFJmq99zp7tX9AoqQDCeqREqmmSIxLeAXO5AFRsbnbca MYDgpwzPu2CTgtVtiFbqxnIkkPB2GP5QXLYmtQD54dj/TACb2LLVB/Ev+Ai49tAZfjqM V3N8p4rFI7M+gWPDvTVIrM+Bi5cmrG7zMp9AWDir4PS0u27AiMyRwWbIR5q/HRqb+4Ld exfheZFWimxm3RtRJWOUlQ/Yz4Rffq3QEFSZvXacPshk62sLiznyyK4UH6xEJbVGwDVJ r25q8B0lxgJI9ViluWfodaNTsyOCDZVQ8XfHjkPxX6Kw63tKdTwk0d6iYT5jpR022L4l ybnw== 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=OYgqExrd4EXuuO1D6Ww0Q1CdWXTOsm/RjoYQacjMg4g=; b=a4txXrEfIQfe3hTYkmV5P4l9Ej4eKdrZ2fU4UjZEbh92370o8mlW1qKCkK4kQKMv6p IfPRdJXUGKanVRVioLgFPGio56BbhOjUTsZbYG2N+lqDpQKu+PpLDHBtksA8Ycn+Zudl 5tjGYwLq4v4bh4SmDKaBXjgFkjH30BC0PWebTQUy4xgR0Ly9kEqqyyNTrgUd1Ta7yecd Ns8v/x5futZ6ZnUZ1bQJJxW70MFkhZC3vWXdj3fBVMbtKjaEOEG5s5MCPFalm93Ozi+M kSo6rPA/VYAI2oIQ16rAlR+Po5EvdE9zUHZa9nyfEATcZYKdPPAIAR/l3JMfkFSr1paO HCMA== X-Gm-Message-State: AN3rC/7TbNrWHQ45M2ifKPvGvYey5VvNHRMvygiOWxOWKmMRmrF/4m9U Y3dW0BSGlbt2cipa9G7gbFfh+3619ZPs X-Received: by 10.80.179.148 with SMTP id s20mr6249610edd.100.1493139224851; Tue, 25 Apr 2017 09:53:44 -0700 (PDT) Original-Received: by 10.80.138.150 with HTTP; Tue, 25 Apr 2017 09:53:44 -0700 (PDT) In-Reply-To: <878tmpoi3x.fsf@dustycloud.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:13629 Archived-At: Hi :) 2017-04-24 19:01 GMT+02:00 Christopher Allan Webber : > 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". > I think that there's no need to be super-consistent here. Actually, I can't think of any natural and elegant use of a boolean variable from the top of my head, but my gutt feeling is that it usually can be avoided (however, if you have some particular examples on your mind, I think it could be instructive to see them here). Also, there seems to be many aspects of this. When we're using a name inside a let or let* form, it shouldn't be very harmful to use question mark in the name of an intermediate variable. The thing with function parameters and global names are I believe more important, because they are a part of some interface. As for parameter names, I'm not sure whether it is a good idea to use question marks in the names that ought to refer to predicates. I'm not sure if it is better for a prototype of "filter" to be (filter condition? list) or (filter condition list) Actually, I find it more natural to interpret the predicate as a boolean flag to a function, rather than a predicate. That said, I think it is a bad practice to make boolean flags arguments to functions, because it is impossible to say how (f #false #true #false) differs from (f #true #true #true) nor what the roles of these arguments are (which is why I think the interface of "format" sucks) Hinldley-Milner languages avoid this problem, because a type signature tells more than just a name (and is more reliable), and they handle tagged unions easily, and it is much better to define a union and use one of its values, than a boolean value (and using Lisp symbols for this purpose, although more readable, is error prone and likely less efficient) Best regards, Panicz