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>; dated Sun, 29 Mar 2009 15:35:04 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
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: Mon, 25 Nov 2019 12:00:02 UTC

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