From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id aOr0JhUZ2mWvqAAAqHPOHw:P1 (envelope-from ) for ; Sat, 24 Feb 2024 17:28:05 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id aOr0JhUZ2mWvqAAAqHPOHw (envelope-from ) for ; Sat, 24 Feb 2024 17:28:05 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=OkSV2bjk; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1708792085; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=HFOFS06MUJtG++UXnq3YBs1uR3FSzEPTtV9TmOm93HI=; b=C9ENr3IjpIDHL+ZGLc6ZXdkbCYFdx5Z/wxsddZW9oXW3d/mAnuRiCijcBivfpiZpO0TnMS GaBChlEpN5rHHOSQm1GeWiAusaScFaH6Va9gqfjOuVUDMkgc5seWz8/J3e0kwTDQu17Dm5 ddBIyxh9JLHUUp5faBET/igjOA/OZHqy7GLmX2pm89HcNDzYjSHO4Rw4TX6PkS5HIEdSDl BXpJpmmIE1uRaFl0m+zDjTXWz+YKwy/IH3OF7JKjAK8SwNu9Mo2HRzBXqhMxFqZeMJbi1H wmKHhpQxhm0CJKRbDZTmmyZ9XxQjLMrktEQJfOET/dIKSXKfqk5rARDBAs8Z8g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=OkSV2bjk; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1708792085; a=rsa-sha256; cv=none; b=pFdnoJLf1VH52osvt8bpRNFaw9MND0HerXngjzpNf330A3GxfVxFNqVdSSE7LsDd5ogYwI 2GWUIdos9ujS1lJdj8MpHIL+LLoy47NlwFy5FLUcr3K2TJpZBT8KCW4ZeJVohPokTNovRn vNb0P5dJbkvOLNCfCCnBfJXsj2c+Pal63RmTz0A1cvYcwI/A4hhRzRleXeasvtOBB1WRER TML0cMldNk2zjK5asVBvvQSsRCz7V55S4ZxEohBDsOQ/DOj07aaoEpyam69Sq9ENw+mguX VZxD2jypgWNneBRJ3yfaQlQiYWKUjAsC44lxLvxq+DaoWSbgObviED1SSoBgQQ== 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 7E8335D568 for ; Sat, 24 Feb 2024 17:28:05 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdus7-0001bS-Hv; Sat, 24 Feb 2024 11:27:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdus5-0001at-Je for guix-devel@gnu.org; Sat, 24 Feb 2024 11:27:30 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdus5-0005Cg-9w; Sat, 24 Feb 2024 11:27:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=HFOFS06MUJtG++UXnq3YBs1uR3FSzEPTtV9TmOm93HI=; b=OkSV2bjktXf0HVlHExZC dAQTqEuKRUwhEs6L94tKcNAb+vV5kPYbzfcME69tEyKdU9Vkz5ZP3/tmEswS02NtLZ+e7je4a9KXR PEssh4xO5Ws3ZqwSH8493uc09C129ACghbuxattVhBH3kZrwPJWVjWE3oO007DU6Bpp/JGL5UcQzJ xlNDxZb0LHcX/2vYjuYSCzi1Kr0d5IaDrKs1aTQjWyfNIWSUQewRXFoYEj5qBFH4sG/+AIMSIGHSW tF48omx5t1Xrb4aEH9LBc6Mge1njMsjsCwbzHEC2iNP5Ex5/rTveOBcw0TUyqxyFEmuYEtbkK5a7D b1pMNruJoGJsjw==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Simon Tournier Cc: Guix Devel Subject: Re: ice-9 match penalty depending on pattern? In-Reply-To: <87wmrh6zwl.fsf@gmail.com> (Simon Tournier's message of "Tue, 06 Feb 2024 22:33:46 +0100") References: <87wmrh6zwl.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Sextidi 6 =?utf-8?Q?Vent=C3=B4se?= an 232 de la =?utf-8?Q?R=C3=A9volution=2C?= jour de l'Asaret X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Sat, 24 Feb 2024 17:27:27 +0100 Message-ID: <87jzmt7rps.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -9.45 X-Spam-Score: -9.45 X-Migadu-Queue-Id: 7E8335D568 X-Migadu-Scanner: mx11.migadu.com X-TUID: 1Qby6tv2nUmB Hey, Simon Tournier skribis: > Re =E2=80=98match=E2=80=99 penalty: when using ellipses in patterns, = the generated > code checks for =E2=80=9Cproper lists=E2=80=9D, which is O(n). The t= rick is to > instead match a pair: > > =E2=9C=94 (match lst ((head . tail) =E2=80=A6)) > =E2=9D=8E (match lst ((head tail ...) =E2=80=A6)) To clarify, my message should not be understood as =E2=80=9Cnever use ellip= ses in =E2=80=98match=E2=80=99 patterns=E2=80=9D. Whether using ellipses is a =E2=80=9Cpenalty=E2=80=9D depends on the contex= t. In some cases I use ellipses anyway because it=E2=80=99s more accurate, more pleasa= nt to the eye, because the input list is small, and/or because this is not performance-critical code. Having a disjoint type for proper lists would avoid this problem, as I mentioned on the Fediverse, but we=E2=80=99re not there yet=E2=80=A6 Ludo=E2=80=99.