From: bolega on
After searching google groups and emacs apropos extensively, I could
not find a function, perhaps I am missing one that can return
identically return its argument and has a small side effect of echoing
the argument in some place such as for example

the mini buffer or the point at which C-x C-e is typed.

For example, calling this function "echo" , usage would look like
this :

(cdr ( echo (cdr (echo (cdr (echo '(a b c d)))))))

echo:
'(a b c d) or (a b c d) (I am not sure which would be appropriate)
(b c d)
(c d)

result:
(d)

Is there a need for quotes to prevent evaluation of alphabets at any
phase ?

Thanks.
From: Pascal J. Bourguignon on
bolega <gnuist006(a)gmail.com> writes:

> After searching google groups and emacs apropos extensively, I could
> not find a function, perhaps I am missing one that can return
> identically return its argument and has a small side effect of echoing
> the argument in some place such as for example
>
> the mini buffer or the point at which C-x C-e is typed.
>
> For example, calling this function "echo" , usage would look like
> this :
>
> (cdr ( echo (cdr (echo (cdr (echo '(a b c d)))))))
>
> echo:
> '(a b c d) or (a b c d) (I am not sure which would be appropriate)
> (b c d)
> (c d)
>
> result:
> (d)
>
> Is there a need for quotes to prevent evaluation of alphabets at any
> phase ?

In Common Lisp, you can use PRINT for this.


CL-USER> (cdr (print (cdr (print (cdr (print '(a b c d)))))))

(A B C D)
(B C D)
(C D)
(D)
CL-USER>



In emacs lisp too, but the output of print goes to the *Message* buffer.

M-x ielm RET
ELISP> (cdr (print (cdr (print (cdr (print '(a b c d)))))))
(d)

and you get:

(a b c d)

(b c d)

(c d)

in the minibuffer and in *Message*.


Or, in an emacs lisp buffer:

(cdr (print (cdr (print (cdr (print '(a b c d))))))) C-u C-x C-e

inserts:

(a b c d)

(b c d)

(c d)
(d)


--
__Pascal Bourguignon__ http://www.informatimago.com/
From: bolega on
On Aug 10, 4:03 pm, p...(a)informatimago.com (Pascal J. Bourguignon)
wrote:
> bolega <gnuist...(a)gmail.com> writes:
> > After searching google groups and emacs apropos extensively, I could
> > not find a function, perhaps I am missing one that can return
> > identically return its argument and has a small side effect of echoing
> > the argument in some place such as for example
>
> > the mini buffer or the point at which C-x C-e is typed.
>
> > For example, calling this function "echo" , usage would look like
> > this :
>
> > (cdr ( echo (cdr (echo (cdr (echo '(a b c d)))))))
>
> > echo:
> > '(a b c d) or (a b c d)  (I am not sure which would be appropriate)
> > (b c d)
> > (c d)
>
> > result:
> > (d)
>
> > Is there a need for quotes to prevent evaluation of alphabets at any
> > phase ?
>
> In Common Lisp, you can use PRINT for this.
>
> CL-USER> (cdr (print (cdr (print (cdr (print '(a b c d)))))))
>
> (A B C D)
> (B C D)
> (C D)
> (D)
> CL-USER>
>
> In emacs lisp too, but the output of print goes to the *Message* buffer.
>
> M-x ielm RET
> ELISP> (cdr (print (cdr (print (cdr (print '(a b c d)))))))
> (d)
>
> and you get:
>
> (a b c d)
>
> (b c d)
>
> (c d)
>
> in the minibuffer and in *Message*.
>
> Or, in an emacs lisp buffer:
>
> (cdr (print (cdr (print (cdr (print '(a b c d))))))) C-u C-x C-e
>
> inserts:
>
> (a b c d)
>
> (b c d)
>
> (c d)
> (d)
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/

THANKS A LOT !!!

If you dont mind, how many years have you spent on learning emacs/
lisp ?

Can you kindly give a reading syllabus, books list and possibly time
for completion from your perspective and what to get out of each book
since they have some common repetition.

Are there any implicit quotations taking place in the above sequence
of cdr, print ... ?

Bolega

From: Pascal J. Bourguignon on
bolega <gnuist006(a)gmail.com> writes:

> On Aug 10, 4:03�pm, p...(a)informatimago.com (Pascal J. Bourguignon)
> wrote:
>> bolega <gnuist...(a)gmail.com> writes:
>> > After searching google groups and emacs apropos extensively, I could
>> > not find a function, perhaps I am missing one that can return
>> > identically return its argument and has a small side effect of echoing
>> > the argument in some place such as for example
>>
>> > the mini buffer or the point at which C-x C-e is typed.
>>
>> > For example, calling this function "echo" , usage would look like
>> > this :
>>
>> > (cdr ( echo (cdr (echo (cdr (echo '(a b c d)))))))
>>
>> > echo:
>> > '(a b c d) or (a b c d) �(I am not sure which would be appropriate)
>> > (b c d)
>> > (c d)
>>
>> > result:
>> > (d)
>>
>> > Is there a need for quotes to prevent evaluation of alphabets at any
>> > phase ?

No. Expressions are evaluated only by EVAL or LOAD (and at
compilation time, compilation time expressions by COMPILE and
COMPILE-FILE). Otherwise, values are just values, they don't get
evaluated magically (for what reason should they?)


>> In Common Lisp, you can use PRINT for this.
>>
>> CL-USER> (cdr (print (cdr (print (cdr (print '(a b c d)))))))
>>
>> (A B C D)
>> (B C D)
>> (C D)
>> (D)
>> CL-USER>
>> [...]
>
> If you dont mind, how many years have you spent on learning emacs/
> lisp ?

20 years.


> Can you kindly give a reading syllabus, books list and possibly time
> for completion from your perspective and what to get out of each book
> since they have some common repetition.

http://www.cliki.net/admin/search?words=books

In particular, I like to advise:

Common Lisp: A Gentle Introduction to Symbolic Computation
http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index.html
http://www.cs.cmu.edu/~dst/LispBook/



> Are there any implicit quotations taking place in the above sequence
> of cdr, print ... ?

Since CDR and PRINT are function, no implicit quotation occurs: the
result values are directly passed as argument to the next function.

Only macros receive their arguments un-evaluated, which could be
characterized as an "implicit quotation".


--
__Pascal Bourguignon__ http://www.informatimago.com/
From: Captain Obvious on
b> If you dont mind, how many years have you spent on learning emacs/
b> lisp ?

I think I've learned about PRINT function on my first day learning CL.
It is not terribly hard to understand what it does without even reading
documentation:

* (print "foobar")

"foobar"
"foobar"

You see two foobars -- one is printed and another is returned. If you're
using SLIME they will be in different colors.