From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] add compiled regexp primitive lisp object Date: Wed, 07 Aug 2024 15:40:37 +0200 Message-ID: <87o764sb6y.fsf@gmail.com> References: <87mslxxddk.fsf@protonmail.com> <5He97LtsyeyQoTLU7d91oP2CLO8s_2afdgcNxozsFjzu8qGbB_7nXmsZL5O6Ej7K-tuEmngCcPKJpDAjxeKz4jk1DvqSUbdOLpw5U1vo1SY=@hypnicjerk.ai> <87le1avopk.fsf@protonmail.com> <2LOLmIp1X8w4CGbqq3qDrzmKVA0KzYNL1N9lBtWdB-MtEv9oCuYgJMYprG170wMPjYxeQImAmWOPatGTTl4KxZMlptNo9A9hnHt84vdN9EA=@hypnicjerk.ai> <87ttfxtszi.fsf@protonmail.com> <86r0b1o5sr.fsf@gnu.org> <868qx8o83w.fsf@gnu.org> <875xscec62.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5978"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , Danny McClanahan , pipcet@protonmail.com, emacs-devel@gnu.org, mattiase@acm.org, acorallo@gnu.org, monnier@iro.umontreal.ca, stefankangas@gmail.com To: Helmut Eller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 07 15:41:28 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sbgut-0001Tb-CV for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Aug 2024 15:41:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbguD-0004FN-Ot; Wed, 07 Aug 2024 09:40:45 -0400 Original-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 1sbguC-0004Es-E0 for emacs-devel@gnu.org; Wed, 07 Aug 2024 09:40:44 -0400 Original-Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbguA-0004Xf-Qk; Wed, 07 Aug 2024 09:40:44 -0400 Original-Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5afa207b8bfso1834272a12.0; Wed, 07 Aug 2024 06:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723038040; x=1723642840; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=FBi8mmzceYmWUZEjMRcqG0gFiw6yaFLHJeqDA9IbObE=; b=SETVizeXavuIAdfGaePIPX3dMYzoJDDK+vMdycB7qW6UMdvrza21k3RHRj5b4oHVhy vTFR36aOia/Na+GL8obxBwR8dHbX+oTeX7pQHFohYi59xGzZ3mv1bu566R9uSvq1rFx+ I2Ghm9N5n3DHch5KAQ8PSFLou/eKFCNvCryf36N/Vy0Kky0ZE/9eBmzCo/FEYbsTK6d3 goRjYcU3oFmIn0IaFfzeh5llKZROpWI37pW/cmPHKkOdGUwOnLr/au/IuKCDlcM0sIMu /gRFExzY26B5KpZMXhjeA1Owxn1LCoNQJMEdwn1xmzfiE7o9KhGn6BOomyHFMPC0uis9 lNaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723038040; x=1723642840; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FBi8mmzceYmWUZEjMRcqG0gFiw6yaFLHJeqDA9IbObE=; b=YEMCz2e5zTqLWy62llTt1je/CaN1HbNZC9rA/xu1FjN44dLBkCjvoDuFmT4fLavaqg EnxLsP9tePdU9rTNm6Iu1zACGdqQYCQ/dY/4Z1Yz/qkrlvrW5xS633hnJJL+s/F5ptJj Zy+RNFzWDvFOMqw8Vfw3sFOjjgjHt7VKNrOKirb/Hhyup0uThlX7EErGH4pqpGFNJdzE wnBhbzJpJuwxJtqfpL7CfwXOD0Wk63BIDfahmktHBcpKPf+QrYrrMGQJzwrnHXnF+wG1 bqUPxzhbmP4ZhbCfzv63F36nAk1dmzZ33WkJq++409oNwKr0vTknix/ETJnRRi9txKUI sj1w== X-Forwarded-Encrypted: i=1; AJvYcCVnIj80XzWfz0IJGHPcF5fWJDUjSZa/mUavDqYIXBeje15quQNe9j4d09XNIMUcsHAocono5kxLQ2V7iKMG5mIKnecyDVHhyIe0tq9+3zh1jhsJ+lkM X-Gm-Message-State: AOJu0YxcV8/7yb7ACIHmuP+0yiwd5zo/mqjG8proV9Iv0Gg+W7bBHDuS DdmNTuNPXYoRow1KIwq48pOUtbLTpFXRxzG9bZoJLJEDrQd3dYK1 X-Google-Smtp-Source: AGHT+IGiSTFWb0uIrWS0OQhRWWYvrUwxRiCNXdbTMremI5IS2DfVJjX4vLJPlZUCNuKon3sWDCGsAA== X-Received: by 2002:a05:6402:1394:b0:57d:2659:9141 with SMTP id 4fb4d7f45d1cf-5b7f51291bamr11981022a12.24.1723038040252; Wed, 07 Aug 2024 06:40:40 -0700 (PDT) Original-Received: from ars3 ([89.246.250.22]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5b83a03b95fsm6997436a12.46.2024.08.07.06.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 06:40:39 -0700 (PDT) In-Reply-To: <875xscec62.fsf@gmail.com> (Helmut Eller's message of "Wed, 07 Aug 2024 14:43:17 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=arstoffel@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:322505 Archived-At: On Wed, 7 Aug 2024 at 14:43, Helmut Eller wrote: > On Wed, Aug 07 2024, Eli Zaretskii wrote: > > [...] >> So these are two (or maybe even one) advantages, mainly in the >> convenience area. My counter-argument would be that the long history >> of using the current regexps in Emacs means that these advantages are >> relatively minor. I'm not sure they justify adding new objects into >> Emacs Lisp, with all its baggage. But maybe others will disagree with >> me. >> >> Are there other advantages? > > An advantage of regex objects is that they don't require the regexp > cache. The regex cache is relatively small (20 entries) and e.g. in the > *scratch* buffer, the font lock regexps are recompiled on every > keystroke because the cache doesn't have enough capacity. > Interestingly, this seems to have very little performance impact. > > Of course, one could make the cache bigger, but for things like font > lock, pre-compiled regexps seem like a good solution. Ignoring the issue that regexps may be syntax-table dependent and other complications (issues which also would need to be addressed in the proposed approach), what would be the advantage of exposing compiled regexp objects versus having an infinite regexp cache? If a long-living string (e.g. a string literals appearing in Elisp/bytecode files) is used once as a regexp, it will presumably be used often as such; so it seems to make sense to keep the cached regexp around forever (in the same way that one would keep the regexp object around forever). If a short-lived string is used as a regexp (e.g. an isearch query), one could just as well wait and deallocate the cached regexp at the time when the string is garbage-collected (in the same way that the compiled regexp object would be garbage-collected at some point). I fail to imagine a case where one would want to let the regexp object be garbage-collected but keep the string around.