GNU bug report logs - #2816
regexp-opt: does not optimize 'Abc' and 'abc'

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Jari Aalto <jari.aalto@HIDDEN>; Done: Stefan Kangas <stefankangas@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 2816-close <at> debbugs.gnu.org:


Received: (at 2816-close) by debbugs.gnu.org; 11 Mar 2025 16:46:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 11 12:46:22 2025
Received: from localhost ([127.0.0.1]:45272 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ts2kI-0003xK-JY
	for submit <at> debbugs.gnu.org; Tue, 11 Mar 2025 12:46:22 -0400
Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:59726)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>)
 id 1ts2kE-0003wq-En
 for 2816-close <at> debbugs.gnu.org; Tue, 11 Mar 2025 12:46:19 -0400
Received: by mail-ed1-x536.google.com with SMTP id
 4fb4d7f45d1cf-5e5c7d6b96fso9375294a12.3
 for <2816-close <at> debbugs.gnu.org>; Tue, 11 Mar 2025 09:46:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1741711572; x=1742316372; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:mime-version:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=kAz+AGUj5iB4lEgDt0GGbqv8kNnKpvYX8K4qkKqtkx0=;
 b=cym+PqpoZQzuaSqk1tCrtcog9uHHNDHM12frTRRHlw6HZuIxm6f9HdptXKJ7DXSqbz
 J3tSMvhXBF3cuo9Q18lQDmYzyhSovNkjYDjMP07OI3/CIgAcsTX8e8Z8OdKGQAFSWqzR
 fur9Rck4JcFFn4K+Npa8X3v6rOyXdqZS8fZ0xD3RTs+v7wuV07zH3ULLuWLw5ZDrrs8X
 uoaXOEX2gJMdDCmhUlFdnkd6GoVw93QFC/zEiC3TN1XjyRAXIbMxabrRpWIbo8nZW3Se
 Ums+Rvra/usg9EELacsBQf14uVY9/jLfZlnexy8L2yo3Czgcx7wxkIUU0UpbAuCzCoHP
 8DdA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1741711572; x=1742316372;
 h=cc:to:subject:message-id:date:mime-version:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=kAz+AGUj5iB4lEgDt0GGbqv8kNnKpvYX8K4qkKqtkx0=;
 b=p7uTXLTNCl8H13zaWsBCfARYchHg9fQFQCpZOZ2Q4bhMw3Rz4b5l2Km3vitp79ssCc
 KpWl+nd7xZ2edVKr/L7ymzzc2cM0FLJSGkVUJS+sxtkh7PCnzLdA2A/gp/D+gpWMzShF
 AHeyS5QDhc8z+CfmRrt7uvepbHjaouB+E7ff9IDs/s+/HhrksZ6nEeVLz3Q1I2RHZDRp
 49YkSF+yEcgYVXCXv3k2vp0l0dIe7T1Ugbpi2GX43fqciGL5fiWUUugz5tYFjvcVg5xN
 ++03ync+ZPUfZNmkFqpNjzreUJudKd1E1nQlvJelDXGaMCUpv+RPsM8Y6g3MlRmfacPk
 2SIw==
X-Forwarded-Encrypted: i=1;
 AJvYcCUv5/1lA9sWxbRLPuKPermtjA9pG6HQUrBBSGM7d0GjlFp46Ppd7sGQoccRm0uc6xYw5NS8NCzHqEgD <at> debbugs.gnu.org
X-Gm-Message-State: AOJu0YxKpGKwymihe0fHBFFMq+oxg/kJsZljyDsH4vNGHafAVjbZzuLm
 ibg+FgV8vmiC7NkuezAlBdwoY7JEZDdlIzocDh2Kndq+iL4g164/87sQ4OLpnwAPGZEt9BOXnLU
 UBmP2MNLEreyvc5ZNSh3GjpG0BrE=
X-Gm-Gg: ASbGncvgv106MdUhBtrar3flvSOgHVXUNV1lcNMVdnT9kwdMpnFne4RPoR8nvBqUROO
 twQfKYx5diKnhPr5Nk8c4oCZcJaZF14myvddCJ78vcHcX0G66EDV4fQa4y5U8w8V4N81SCTyb+n
 JJDgDtzr5y3ZEwglw+IslbOFSnsQ==
X-Google-Smtp-Source: AGHT+IHT/iBIT5GxoNiWqFOygQahuz0E86mK60S1ApGMIS+6cbjrpYPzlQ1cWz2bZbk9fMHPyQYWREY4F8RmyVyfCR0=
X-Received: by 2002:a05:6402:1912:b0:5e5:bdfe:6bfb with SMTP id
 4fb4d7f45d1cf-5e5e2319be8mr21795867a12.16.1741711571814; Tue, 11 Mar 2025
 09:46:11 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Tue, 11 Mar 2025 09:46:10 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
MIME-Version: 1.0
Date: Tue, 11 Mar 2025 09:46:10 -0700
X-Gm-Features: AQ5f1JqBIcOj-0GE5rrZbpwr1qve_S0ieaVk-3VWaVDVuOz1VTt1Dy1uDkus6dQ
Message-ID: <CADwFkmmD2mcnHT3YraK0ncqvOngZrCGoZEvXi_r=rfr4eF3gXg@HIDDEN>
Subject: Re: bug#2816: regexp-opt: does not optimize 'Abc' and 'abc'.
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 2816-close
Cc: 2816-close <at> debbugs.gnu.org, Jari Aalto <jari.aalto@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stefan Monnier <monnier@HIDDEN> writes:

>> A)
>
>>     (regexp-opt
>>       '("Abc"
>>         "abc"))
>
>>     => "\\(?:[Aa]bc\\)"
>
>> B)
>
>>     (regexp-opt
>>       '("Abc"
>>         "def"
>>         "abc"))
>
>>     => "\\(?:Abc\\|abc\\|def\\)"
>
>> Shouldn't regexp-opt optimize B case as well?
>
> The `opt' of regexp-opt should be understood in the sense of
> optimization used in compilers, not in the formal mathematical sense of
> "optimal".  I.e. it does some effort to improve things, but without any
> guarantee about what is and what isn't optimized.
>
> So, yes, it would be good if it did do what you suggest, but it's not
> a bug if it doesn't.

Without a proposed patch, I think it's unlikely that we'll make much
progress here.  After 16 years, I'm closing this bug now.

If anyone wants to propose improvements to `regexp-opt`, please open a
new bug report.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#2816; Package emacs. Full text available.

Message received at 2816-close <at> debbugs.gnu.org:


Received: (at 2816-close) by debbugs.gnu.org; 11 Mar 2025 16:44:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 11 12:44:45 2025
Received: from localhost ([127.0.0.1]:45259 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ts2ii-0003nd-Ft
	for submit <at> debbugs.gnu.org; Tue, 11 Mar 2025 12:44:44 -0400
Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:48421)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>)
 id 1ts2ie-0003nI-2e
 for 2816-close <at> debbugs.gnu.org; Tue, 11 Mar 2025 12:44:41 -0400
Received: by mail-ed1-x531.google.com with SMTP id
 4fb4d7f45d1cf-5e5e34f4e89so8736449a12.1
 for <2816-close <at> debbugs.gnu.org>; Tue, 11 Mar 2025 09:44:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1741711473; x=1742316273; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=kAz+AGUj5iB4lEgDt0GGbqv8kNnKpvYX8K4qkKqtkx0=;
 b=dSNjMpw1V7eEzxvmwdltwZHGopqdHDZNy5V+Cg7JNUw3P0+Ku6ygOS4TDic4I9IeVB
 9FRqUOuR+YZP+Jz/dftzUdJNmrENXSjRawXDku4Tvtc9TvzMsLhkDfGWeZ4VpmTr/i+b
 nVSc4nrW1XRBvUEpoeAQb0xNC8D1eVEUn6y/8oEVkp3bph+nl9f39raU1wetWVVN6Z+X
 Y9OPFtT3y+xvFCsghIrMth5Tse7Omt0iX915nhsgXVLC1lLuhw3CzXgMg+auvHcUs82Y
 qibcaTNkA8pDKBrKq/tgE8RVugLZ/C8ZpnXG8dWEhuhvO5mP0AvOptdnr6+c0Yj++K4/
 SjuA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1741711473; x=1742316273;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=kAz+AGUj5iB4lEgDt0GGbqv8kNnKpvYX8K4qkKqtkx0=;
 b=Za5+EDUGmATzLleLm7W8G3JvCbmd0mpr1Oj0gpg/czXxCufEHVnNhfWRmySuK0fWad
 aZWmWU/okonRgmt50BvYpNMEGr537ladbGx83RjzAzz4ZaNZOmaKbV26kVneK6GkqkAe
 n7O7nUOcILVKKZRMaq0dOlFPZH4i9oQG4zIRnM3Lh/lVUkgbaUm8As7bFDyA71jGF9tO
 XlB7UgoG3ZlGWpgQ42ornTvoad138SX73r8CAOMdt/8vpPGTouv9xwxuCAFL6dep08RM
 ghJ36h6s0TiTpmzFD1GUBqQbvYHnmD7oP40f9UrhzY2aUeVUTMkdUetVj2hMmC+2PHUl
 endA==
X-Forwarded-Encrypted: i=1;
 AJvYcCWnZ47MCjiAO5IjepF4+QEhNLpGU42BFbHcNhvW/glxJsPZPkIwVdCooNCbT3RT5tWLWdUS2YgFroj7 <at> debbugs.gnu.org
X-Gm-Message-State: AOJu0Yz3/xNOcvoS+IsK7aaiWoZqUt24l1+yHtkmiZX5kAnFm1TYPu6V
 sdOMLxO+uUCfgdz1VPu7lyr4NQNr8C+qsnDuKANVqnvfV/KZBxdqgwZzze7UT5P6HK/dVkJXOTk
 UBSdmZnKm1KskirrGg6c5jy6FhlE=
X-Gm-Gg: ASbGncsTtC+nmEbhtvCmHgq8hnsrxhxvKkwYnrvQoxoGfgJz1ESModKUrzG3inpbX7B
 cYucvE/ZWoq2cdQ3c40SQVHryPzSgFkg/w3BYN0UWVFX0hNNT8UNJHQVxQk53AyME3ufIT7hGS+
 9lAu2xsewHbbLRSoNvH4BoyuBbbQ==
X-Google-Smtp-Source: AGHT+IHKFC6OdYtXHjHDEL1TM6F476bq9BIgHbOzgQ6D3OZ3FV17q2k9BT2mZOCg8fLJTkYitchoq12bG49Rot/2lgc=
X-Received: by 2002:a05:6402:254c:b0:5e0:8937:6ef2 with SMTP id
 4fb4d7f45d1cf-5e5e22bf4b1mr17871003a12.8.1741711472598; Tue, 11 Mar 2025
 09:44:32 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Tue, 11 Mar 2025 09:44:31 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <jwvy6uo9rwy.fsf-monnier+emacsbugreports@HIDDEN>
References: <877i28nya0.fsf@HIDDEN>
 <jwvy6uo9rwy.fsf-monnier+emacsbugreports@HIDDEN>
MIME-Version: 1.0
Date: Tue, 11 Mar 2025 09:44:31 -0700
X-Gm-Features: AQ5f1JrC4UzY6lsSeGzREFHwAyHi8_hlYlbMsH6Nvk_DjygVIW1zc3h8FSMa_4c
Message-ID: <CADwFkm=pQCeEStU-VgsseMXi8+FRaBczVHMfGeh5tZtQ7O5VFQ@HIDDEN>
Subject: Re: bug#2816: regexp-opt: does not optimize 'Abc' and 'abc'
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 2816-close
Cc: 2816-close <at> debbugs.gnu.org, Jari Aalto <jari.aalto@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stefan Monnier <monnier@HIDDEN> writes:

>> A)
>
>>     (regexp-opt
>>       '("Abc"
>>         "abc"))
>
>>     => "\\(?:[Aa]bc\\)"
>
>> B)
>
>>     (regexp-opt
>>       '("Abc"
>>         "def"
>>         "abc"))
>
>>     => "\\(?:Abc\\|abc\\|def\\)"
>
>> Shouldn't regexp-opt optimize B case as well?
>
> The `opt' of regexp-opt should be understood in the sense of
> optimization used in compilers, not in the formal mathematical sense of
> "optimal".  I.e. it does some effort to improve things, but without any
> guarantee about what is and what isn't optimized.
>
> So, yes, it would be good if it did do what you suggest, but it's not
> a bug if it doesn't.

Without a proposed patch, I think it's unlikely that we'll make much
progress here.  After 16 years, I'm closing this bug now.

If anyone wants to propose improvements to `regexp-opt`, please open a
new bug report.




Notification sent to Jari Aalto <jari.aalto@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Stefan Kangas <stefankangas@HIDDEN>:
You have taken responsibility. Full text available.
Tags removed: patch Request was from Glenn Morris <rgm@HIDDEN> to control@HIDDEN. Full text available.
Severity set to `wishlist' from `normal' Request was from Jari Aalto <jari.aalto@HIDDEN> to control@HIDDEN. Full text available.

Message received at 2816@HIDDEN:


Received: (at 2816) by emacsbugs.donarmstrong.com; 29 Mar 2009 17:13:25 +0000
From monnier@HIDDEN Sun Mar 29 10:13:24 2009
X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02
	(2008-06-10) on rzlab.ucr.edu
X-Spam-Level: 
X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available.
	hammytokens:Tokens not available.
X-Spam-Status: No, score=-0.5 required=4.0 tests=HAS_BUG_NUMBER,XIRONPORT
	autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02
Received: from ironport2-out.teksavvy.com (ironport2-out.teksavvy.com [206.248.154.182])
	by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n2THDFE7009118;
	Sun, 29 Mar 2009 10:13:17 -0700
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AlMFAHNJz0lFxIfy/2dsb2JhbACBUcYdg3oGhHc
X-IronPort-AV: E=Sophos;i="4.38,442,1233550800"; 
   d="scan'208";a="35897495"
Received: from 69-196-135-242.dsl.teksavvy.com (HELO pastel.home) ([69.196.135.242])
  by ironport2-out.teksavvy.com with ESMTP; 29 Mar 2009 13:13:10 -0400
Received: by pastel.home (Postfix, from userid 20848)
	id 7111C8682; Sun, 29 Mar 2009 13:13:09 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Jari Aalto <jari.aalto@HIDDEN>
Cc: 2816 <at> debbugs.gnu.org,
        Emacs bug BTS <submit <at> debbugs.gnu.org>
Subject: Re: bug#2816: regexp-opt: does not optimize 'Abc' and 'abc'
Message-ID: <jwvy6uo9rwy.fsf-monnier+emacsbugreports@HIDDEN>
References: <877i28nya0.fsf@HIDDEN>
Date: Sun, 29 Mar 2009 13:13:09 -0400
In-Reply-To: <877i28nya0.fsf@HIDDEN> (Jari Aalto's message of "Sun,
	29 Mar 2009 18:28:55 +0300")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii

> A)

>     (regexp-opt
>       '("Abc"
>         "abc"))

>     => "\\(?:[Aa]bc\\)"

> B)

>     (regexp-opt
>       '("Abc"
>         "def"
>         "abc"))

>     => "\\(?:Abc\\|abc\\|def\\)"

> Shouldn't regexp-opt optimize B case as well?

The `opt' of regexp-opt should be understood in the sense of
optimization used in compilers, not in the formal mathematical sense of
"optimal".  I.e. it does some effort to improve things, but without any
guarantee about what is and what isn't optimized.

So, yes, it would be good if it did do what you suggest, but it's not
a bug if it doesn't.


        Stefan




Acknowledgement sent to Stefan Monnier <monnier@HIDDEN>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs@HIDDEN>. Full text available.
Information forwarded to bug-submit-list@HIDDEN, Emacs Bugs <bug-gnu-emacs@HIDDEN>:
bug#2816; Package emacs. Full text available.

Message received at submit@HIDDEN:


Received: (at submit) by emacsbugs.donarmstrong.com; 29 Mar 2009 17:13:25 +0000
From monnier@HIDDEN Sun Mar 29 10:13:24 2009
X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02
	(2008-06-10) on rzlab.ucr.edu
X-Spam-Level: 
X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available.
	hammytokens:Tokens not available.
X-Spam-Status: No, score=-0.5 required=4.0 tests=HAS_BUG_NUMBER,XIRONPORT
	autolearn=unavailable version=3.2.5-bugs.debian.org_2005_01_02
Received: from ironport2-out.teksavvy.com (ironport2-out.teksavvy.com [206.248.154.182])
	by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n2THDFE7009118;
	Sun, 29 Mar 2009 10:13:17 -0700
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AlMFAHNJz0lFxIfy/2dsb2JhbACBUcYdg3oGhHc
X-IronPort-AV: E=Sophos;i="4.38,442,1233550800"; 
   d="scan'208";a="35897495"
Received: from 69-196-135-242.dsl.teksavvy.com (HELO pastel.home) ([69.196.135.242])
  by ironport2-out.teksavvy.com with ESMTP; 29 Mar 2009 13:13:10 -0400
Received: by pastel.home (Postfix, from userid 20848)
	id 7111C8682; Sun, 29 Mar 2009 13:13:09 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Jari Aalto <jari.aalto@HIDDEN>
Cc: 2816 <at> debbugs.gnu.org,
        Emacs bug BTS <submit <at> debbugs.gnu.org>
Subject: Re: bug#2816: regexp-opt: does not optimize 'Abc' and 'abc'
Message-ID: <jwvy6uo9rwy.fsf-monnier+emacsbugreports@HIDDEN>
References: <877i28nya0.fsf@HIDDEN>
Date: Sun, 29 Mar 2009 13:13:09 -0400
In-Reply-To: <877i28nya0.fsf@HIDDEN> (Jari Aalto's message of "Sun,
	29 Mar 2009 18:28:55 +0300")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-CrossAssassin-Score: 2

> A)

>     (regexp-opt
>       '("Abc"
>         "abc"))

>     => "\\(?:[Aa]bc\\)"

> B)

>     (regexp-opt
>       '("Abc"
>         "def"
>         "abc"))

>     => "\\(?:Abc\\|abc\\|def\\)"

> Shouldn't regexp-opt optimize B case as well?

The `opt' of regexp-opt should be understood in the sense of
optimization used in compilers, not in the formal mathematical sense of
"optimal".  I.e. it does some effort to improve things, but without any
guarantee about what is and what isn't optimized.

So, yes, it would be good if it did do what you suggest, but it's not
a bug if it doesn't.


        Stefan



Acknowledgement sent to Stefan Monnier <monnier@HIDDEN>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs@HIDDEN>. Full text available.
Information forwarded to bug-submit-list@HIDDEN, Emacs Bugs <bug-gnu-emacs@HIDDEN>:
bug#2816; Package emacs. Full text available.
Tags added: patch Request was from Jari Aalto <jari.aalto@HIDDEN> to control@HIDDEN. Full text available.

Message received at submit@HIDDEN:


Received: (at submit) by emacsbugs.donarmstrong.com; 29 Mar 2009 15:29:09 +0000
From jari.aalto@HIDDEN Sun Mar 29 08:29:09 2009
X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02
	(2008-06-10) on rzlab.ucr.edu
X-Spam-Level: 
X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available.
	hammytokens:Tokens not available.
X-Spam-Status: No, score=0.0 required=4.0 tests=none autolearn=ham
	version=3.2.5-bugs.debian.org_2005_01_02
Received: from emh06.mail.saunalahti.fi (emh06.mail.saunalahti.fi [62.142.5.116])
	by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n2TFT49H015111
	for <submit@HIDDEN>; Sun, 29 Mar 2009 08:29:06 -0700
Received: from saunalahti-vams (vs3-12.mail.saunalahti.fi [62.142.5.96])
	by emh06-2.mail.saunalahti.fi (Postfix) with SMTP id 8ED40C7B0D
	for <submit@HIDDEN>; Sun, 29 Mar 2009 18:29:03 +0300 (EEST)
Received: from emh01.mail.saunalahti.fi ([62.142.5.107])
	by vs3-12.mail.saunalahti.fi ([62.142.5.96])
	with SMTP (gateway) id A06861741C2; Sun, 29 Mar 2009 18:29:03 +0300
Received: from picasso.cante.net (a91-155-187-216.elisa-laajakaista.fi [91.155.187.216])
	by emh01.mail.saunalahti.fi (Postfix) with ESMTP id 831EE4035
	for <submit@HIDDEN>; Sun, 29 Mar 2009 18:29:02 +0300 (EEST)
Received: from [192.168.1.7] (helo=jondo.cante.net)
	by picasso.cante.net with esmtp (Exim 4.69)
	(envelope-from <jari.aalto@HIDDEN>)
	id 1LnwwT-0001LR-IK
	for submit@HIDDEN; Sun, 29 Mar 2009 18:28:57 +0300
Received: from jaalto by jondo.cante.net with local (Exim 4.69)
	(envelope-from <jari.aalto@HIDDEN>)
	id 1LnwwR-0004zE-7m
	for submit@HIDDEN; Sun, 29 Mar 2009 18:28:55 +0300
From: Jari Aalto <jari.aalto@HIDDEN>
To: Emacs bug BTS <submit <at> debbugs.gnu.org>
Subject: regexp-opt: does not optimize 'Abc' and 'abc'
Date: Sun, 29 Mar 2009 18:28:55 +0300
Message-ID: <877i28nya0.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-SA-Exim-Connect-IP: 192.168.1.7
X-SA-Exim-Mail-From: jari.aalto@HIDDEN
X-SA-Exim-Scanned: No (on picasso.cante.net); SAEximRunCond expanded to false
X-Antivirus: VAMS


A)

    (regexp-opt
      '("Abc"
        "abc"))

    => "\\(?:[Aa]bc\\)"

B)

    (regexp-opt
      '("Abc"
        "def"
        "abc"))

    => "\\(?:Abc\\|abc\\|def\\)"

Shouldn't regexp-opt optimize B case as well?

Jari




Acknowledgement sent to Jari Aalto <jari.aalto@HIDDEN>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs@HIDDEN>. Full text available.
Report forwarded to bug-submit-list@HIDDEN, Emacs Bugs <bug-gnu-emacs@HIDDEN>:
bug#2816; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 11 Mar 2025 17:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.