unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Harry Putnam <reader@newsguy.com>
To: help-gnu-emacs@gnu.org
Subject: Re: conditionals in elisp
Date: Wed, 28 Oct 2009 11:19:25 -0500	[thread overview]
Message-ID: <87639zlcdu.fsf@newsguy.com> (raw)
In-Reply-To: 873a53rij7.fsf@ambire.localdomain

Thien-Thi Nguyen <ttn@gnuvola.org> writes:

>
> If these (nicely formatted) examples are useful, they could be added to
> the documentation.

Yes nice examples all, and helpful.  I guess I came at this more in
line with what is posted at one of the hits Pascal pointed to:

  http://steve-yegge.blogspot.com/2008/01/emergency-elisp.html

This fellow says he was looking to demonstrate examples comparable to
other languages.

His examples of if/else seem to ring a bell for me. 

> Also (to Harry Putnam): You can help avoid misunderstanding from other
> list members by stating explicitly "i read the Emacs Lisp manual node
> "Conditionals" and couldn't understand it".

Throughout this thread I've been a little amazed at how my OP comments
seem to have been taken.

I thought I said with some clarity that I didn't understand reading
the elisp manual.  And laid out further what I was after... simplified
examples of if/else in elisp.

Is the following paragraph really so devoid of intent?

> This may be a chintzy way to do it but I really do not want to pound
> away at elisp intro and the elisp manual for hours.  I usually
> start seeing red at the 4-5 paragraph and usually have been able to
> learn what I needed to know in things like perl and shell scripting
> from  just a few real live examples that do something at least close
> to what I am trying then I can edit and tinker until I start to sort
> of `get it'.
> 

What followed that was a fairly detailed account of what I was trying
to do then asked for simplified examples that did something at least
similar.

But, it certainly did not come across as intended.

Thanks for the examples and tips about testing tinkering etc.

Oh, and do experts here think that page cited above... in particular
the if/else examples, are good?   not so good..?

Reprint of a couple here but there were several more (about 1/3 of the
way down the page cited above and below, if anyone has a mind to look):

  http://steve-yegge.blogspot.com/2008/01/emergency-elisp.html

From Steve Yegge's pages:
,----
|     if/else
| 
| Case 1: no else clause: (if test-expr expr)
| 
| Example:
| 
| (if (>= 3 2)
|   (message "hello there"))
| 
| 
| Case 2: else clause: (if test-expr then-expr else-expr)
| 
| (if (today-is-friday)         ; test-expr
|     (message "yay, friday")   ; then-expr
|   (message "boo, other day")) ; else-expr
| 
| 
| If you need multiple expressions (statements) in the then-expr, you
| wrap them with a call to progn, which is like curly-braces in C or
| Java:
| 
| (if (zerop 0)
|     (progn
|       (do-something)
|       (do-something-else)
|       (etc-etc-etc)))
`----
 [...]





  parent reply	other threads:[~2009-10-28 16:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27  0:08 conditionals in elisp Harry Putnam
2009-10-27  0:25 ` Richard Riley
2009-10-27  1:03 ` Drew Adams
2009-10-27  5:33   ` Harry Putnam
2009-10-27  7:37     ` Drew Adams
2009-10-28  9:10       ` Thien-Thi Nguyen
2009-10-28 14:03         ` Drew Adams
     [not found]         ` <mailman.9621.1256738653.2239.help-gnu-emacs@gnu.org>
2009-10-28 15:42           ` LanX
2009-10-28 20:42             ` Harry Putnam
2009-10-28 16:19         ` Harry Putnam [this message]
     [not found]         ` <mailman.9630.1256746811.2239.help-gnu-emacs@gnu.org>
2009-11-02 19:31           ` Joseph Brenner
2009-10-27  5:50 ` tomas
     [not found] <mailman.9533.1256602126.2239.help-gnu-emacs@gnu.org>
2009-10-27  0:19 ` Pascal J. Bourguignon
2009-10-27  2:52 ` LanX
2009-10-27 10:36   ` Pascal J. Bourguignon
2009-10-27 12:09     ` Richard Riley
2009-10-27 17:03       ` Sean Sieger
2009-10-28 12:07         ` Richard Riley
     [not found]     ` <mailman.9555.1256645401.2239.help-gnu-emacs@gnu.org>
2009-10-27 12:31       ` Pascal J. Bourguignon
2009-10-27 13:02         ` Richard Riley
     [not found]         ` <mailman.9557.1256648714.2239.help-gnu-emacs@gnu.org>
2009-10-27 16:04           ` Pascal J. Bourguignon
2009-10-27 17:26         ` Harry Putnam
     [not found]         ` <mailman.9572.1256664440.2239.help-gnu-emacs@gnu.org>
2009-10-27 18:37           ` Pascal J. Bourguignon
2009-10-27 19:40             ` Harry Putnam
     [not found]             ` <mailman.9577.1256672457.2239.help-gnu-emacs@gnu.org>
2009-10-27 21:14               ` Pascal J. Bourguignon
2009-10-28 14:05                 ` David Kastrup
2009-10-28 15:55                   ` Harry Putnam
2009-10-28 17:45                   ` Pascal J. Bourguignon

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=87639zlcdu.fsf@newsguy.com \
    --to=reader@newsguy.com \
    --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).