From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 0LLxHFjzm1+pWgAA0tVLHw (envelope-from ) for ; Fri, 30 Oct 2020 11:04:56 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id GJ3hGFjzm19LLwAAB5/wlQ (envelope-from ) for ; Fri, 30 Oct 2020 11:04:56 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CAB739401BF for ; Fri, 30 Oct 2020 11:04:55 +0000 (UTC) Received: from localhost ([::1]:34530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYSDG-0006AD-RS for larch@yhetil.org; Fri, 30 Oct 2020 07:04:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYSD5-00069w-6d for guix-devel@gnu.org; Fri, 30 Oct 2020 07:04:44 -0400 Received: from imta-38.everyone.net ([216.200.145.38]:50442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYSD3-0006iT-5I for guix-devel@gnu.org; Fri, 30 Oct 2020 07:04:42 -0400 Received: from pps.filterd (omta003.sj2.proofpoint.com [127.0.0.1]) by imta-38.everyone.net (8.16.0.43/8.16.0.43) with SMTP id 09UB3Elx019990; Fri, 30 Oct 2020 04:04:26 -0700 X-Eon-Originating-Account: WQdEdfeZsAlu9brSd2gBfZC1qpwyG_4GjyVrkzeKOok X-Eon-Dm: m0116293.ppops.net Received: by m0116293.mta.everyone.net (EON-AUTHRELAY2 - 53b92ce6) id m0116293.5f8a0270.182c9e; Fri, 30 Oct 2020 04:04:25 -0700 X-Eon-Sig: AQMHrIJfm/M5foTNTAIAAAAC,8500bde997fac2ef33a87bcfff17dd45 X-Eip: WNNlMcgnbU5YxjSSsvvR2Y6XC_VQBljbxAKyQu37rIo Date: Fri, 30 Oct 2020 12:04:16 +0100 From: Bengt Richter To: Brendan Tildesley Subject: Re: A better way to access records. Message-ID: <20201030110416.GA5579@LionPure> References: <487cea17-061a-2cc9-6b3e-7b688114d158@brendan.scot> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <487cea17-061a-2cc9-6b3e-7b688114d158@brendan.scot> User-Agent: Mutt/1.10.1 (2018-07-13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-10-30_02:2020-10-30, 2020-10-30 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 impostorscore=0 mlxlogscore=849 mlxscore=0 clxscore=1034 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010300085 Received-SPF: pass client-ip=216.200.145.38; envelope-from=bokr@oz.net; helo=imta-38.everyone.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 07:04:38 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Bengt Richter Cc: guix-devel Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Spam-Score: -0.51 X-TUID: CXP2luAisvjx Hi Brendan, On +2020-10-30 21:28:38 +1100, Brendan Tildesley wrote: > From the little bit of SICP that I've done, I recall watching the lectures > where > they put a mage hat on and talk about the power of names. One could perhaps > say > the most powerful tool in a programming language is the ability to give > something a name and then refer to those names. > > In guix/guile, record types are  list of names given to some data. > For example: > > (define foo >   (package >    (name "bar") >    (version "1.0") >    ...) > > Here we the names foo, name, version, that refer to things of interest. We > can > call foo easily enough to get the record, but we cannot refer to name or > version so easily.  We instead have to use accessors like (package-name > foo), > which requires us to write foo each time explicitly and have repeat package- > for each accessor. > In the guix codebase, on many occasions there appear things like this: > > (match-lambda >     (($ agetty tty term baud-rate auto-login >         login-program login-pause? eight-bits? no-reset? remote? > flow-control? >         host no-issue? init-string no-clear? local-line extract-baud? >         skip-login? no-newline? login-options chroot hangup? keep-baud? > timeout >         detect-case? wait-cr? no-hints? no-hostname? long-hostname? >         erase-characters kill-characters chdir delay nice extra-options) >      (list >       .... > > Here we have given some names to things, abandoned those names, and once > again > gone to the trouble of naming them again, in order, just for one local > environment. We'd have to do it again to make use of it elsewhere, and I > assume > they would have to change if the record type it self needed to be updated. > > Wouldn't be nice if we could just step inside a record type whenever we > pleased? > The above would be like this perhaps: > > (let-from-record-type >  (list ...)) > > "let-from-record-type" i just made up since i dont know what it should be > called.  Anyhow, it seems like we're stepping back a few centuries in > computer > science by needing to jump through these hoops. > > The list of symbols can be retreived with (record-type-fields > ), but I can't think of how one would write the above > syntax. > > Opinions? > > > info guile record may be useful :) -- Regards, Bengt Richter