unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: empty-line-p
Date: Sun, 01 Apr 2007 16:54:49 -0400	[thread overview]
Message-ID: <jwv3b3jx1jl.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: barmar-D73634.01465330032007@comcast.dca.giganews.com

>> >  (if (looking-at "^[ \t\f\r]*$")
>> >      t
>> >    nil)))
>> 
>> (if <foo> t nil)
>> 
>> is an eta-regexp, which can be advantageously reduced to just <foo>.
>> 
>> 
>> Stefan
>> 
>> 
>> PS: The classical eta-regexp is (lambda (x) (<foo> x)), which is equivalent to
>> just <foo>.  Another variant is (cons (car <foo>) (cdr <foo>)), which
>> eta-reduces to just <foo>.

> That last one is different, because the new cons is not eq to the 
> original <foo>.

Indeed, the eta rules are generally not supported 100% by most languages:
there are always some "minor" semantic differences.  Aside from the problem
you mentioned for the `cons' case, the `if' case changes the result when the
tested value can be non-t and non-nil, and the `lambda' case can change the
behavior when the function is called with more than 1 argument.

So most compilers don't apply such "optimizations", which makes it that much
more valuable to apply them by hand.


        Stefan

  reply	other threads:[~2007-04-01 20:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1577.1175177310.7795.help-gnu-emacs@gnu.org>
2007-03-29 14:32 ` empty-line-p Joost Kremers
2007-03-30  8:56   ` empty-line-p David Hansen
2007-03-31  5:49     ` empty-line-p Andreas Roehler
2007-03-31 15:17       ` empty-line-p Xavier Maillard
2007-04-06 14:44         ` empty-line-p Andreas Roehler
     [not found]   ` <mailman.1621.1175289074.7795.help-gnu-emacs@gnu.org>
2007-04-01 20:57     ` empty-line-p Stefan Monnier
2007-03-30  5:36 ` empty-line-p Stefan Monnier
2007-03-30  5:46   ` empty-line-p Barry Margolin
2007-04-01 20:54     ` Stefan Monnier [this message]
2007-03-30  6:14   ` empty-line-p Andreas Roehler
2007-03-29 13:06 empty-line-p Andreas Roehler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv3b3jx1jl.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).