[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Return value not as expected in Emacs Lisp function
From: |
Thorsten Jolitz |
Subject: |
Re: Return value not as expected in Emacs Lisp function |
Date: |
Thu, 08 Aug 2013 00:54:43 +0200 |
User-agent: |
Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux) |
"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