all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Return value not as expected in Emacs Lisp function
Date: Thu, 08 Aug 2013 00:54:43 +0200	[thread overview]
Message-ID: <87pptpdscs.fsf@gmail.com> (raw)
In-Reply-To: 87pptpnrba.fsf@informatimago.com

"Pascal J. Bourguignon" <pjb@informatimago.com> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> and I ask myself what happened between the second-last and the last line of
>> the function? I cannot reproduce this with a MWE, and the real function is too
>> convoluted to present it here, so I keep the problem description on an
>> abstract level. 
>
> On an abstract leve, I can't debug a function if I don't have it's
> code.  That's the reason d'être of the MWE, and by default the real code.

I found the error, a misplaced paren. I could not reproduce the error in
a MWE - probably I did not copy the part with the misplaced paren to the
MWE.

>> I'm actually only interested in the result string as a return value, the
>> message statement is just for logging. But why is the string produced by
>> 'mapconcat' missing in the return value?
>
> The real question is why you use mapconcat to produce a string
> representation of a sexp?  Just use prin1-to-string!
>
> (let ((list '((click NIL 1) (press NIL 1) (click NIL 4) (click NIL 1))))
>   (prin1-to-string `(prog ,@list )))
> --> "(prog (click NIL 1) (press NIL 1) (click NIL 4) (click NIL 1))" 
>
> Notice:
>
> - emacs lisp is a lisp-2, not a lst-1.
>
> - NIL is true:
>   
>   (not (not 'NIL))       --> t
>   (not 'NIL)             --> nil
>   (if 'NIL 'true 'false) --> true


I should have said that this 

,-----------------------------------------------------------------
| "(prog (click NIL 1) (press NIL 1) (click NIL 4) (click NIL 1))"
`-----------------------------------------------------------------

is actually PicoLisp, a lisp-1 with NIL and T syntax (uppercase!). I
thought the 'prog in the beginning (PicoLisp's 'progn)  would make it
clear its not Elisp. At least C-h f doesn' show me a 'prog function in
Elisp. 

But thanks for your answer, I did not know `prin1-to-string', and finally
looked up the difference between lisp-1 and lisp-2. 

-- 
cheers,
Thorsten




  reply	other threads:[~2013-08-07 22:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07 18:48 Return value not as expected in Emacs Lisp function Thorsten Jolitz
2013-08-07 21:00 ` Stefan Monnier
2013-08-07 22:47   ` Thorsten Jolitz
2013-08-07 21:07 ` Pascal J. Bourguignon
2013-08-07 22:54   ` Thorsten Jolitz [this message]
2013-08-08 22:31     ` Pascal J. Bourguignon
2013-08-09 12:03       ` Thorsten Jolitz

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

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

  git send-email \
    --in-reply-to=87pptpdscs.fsf@gmail.com \
    --to=tjolitz@gmail.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.