* About `read'
@ 2013-01-04 13:35 Xue Fuqiao
2013-01-04 13:44 ` Teemu Likonen
0 siblings, 1 reply; 4+ messages in thread
From: Xue Fuqiao @ 2013-01-04 13:35 UTC (permalink / raw)
To: help-gnu-emacs
I have a question about read:
(read "(I am) xfq")
=>(I am)
(read "I am xfq")
=>I
Why are they different? When does `read' skip whitespace characters?
--
Best regards, Xue Fuqiao.
http://www.emacswiki.org/emacs/XueFuqiao
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: About `read'
2013-01-04 13:35 About `read' Xue Fuqiao
@ 2013-01-04 13:44 ` Teemu Likonen
2013-01-04 14:03 ` Xue Fuqiao
[not found] ` <mailman.16693.1357308229.855.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 4+ messages in thread
From: Teemu Likonen @ 2013-01-04 13:44 UTC (permalink / raw)
To: Xue Fuqiao; +Cc: help-gnu-emacs
Xue Fuqiao [2013-01-04 21:35:03 +0800] wrote:
> I have a question about read:
>
> (read "(I am) xfq")
> =>(I am)
>
> (read "I am xfq")
> =>I
>
> Why are they different? When does `read' skip whitespace characters?
Function READ reads one Lisp expression. In your first example the first
expression is a list of two symbols. In the second example the first
expression is symbol named "I".
read is a built-in function in `C source code'.
(read &optional STREAM)
Read one Lisp expression as text from STREAM, return as Lisp object.
If STREAM is nil, use the value of `standard-input' (which see).
STREAM or the value of `standard-input' may be:
a buffer (read from point and advance it)
a marker (read from where it points and advance it)
a function (call it with no arguments for each character,
call it with a char as argument to push a char back)
a string (takes text from string, starting at the beginning)
t (read text line using minibuffer and use it, or read from
standard input in batch mode).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: About `read'
2013-01-04 13:44 ` Teemu Likonen
@ 2013-01-04 14:03 ` Xue Fuqiao
[not found] ` <mailman.16693.1357308229.855.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 4+ messages in thread
From: Xue Fuqiao @ 2013-01-04 14:03 UTC (permalink / raw)
To: Teemu Likonen; +Cc: help-gnu-emacs
On Fri, 04 Jan 2013 15:44:16 +0200
Teemu Likonen <tlikonen@iki.fi> wrote:
> Function READ reads one Lisp expression. In your first example the first
> expression is a list of two symbols. In the second example the first
> expression is symbol named "I".
Thanks, I see.
> a function (call it with no arguments for each character,
> call it with a char as argument to push a char back)
When STREAM is a function called with one argument, what does `push a char back' mean? Where will the char be pushed?
--
Best regards, Xue Fuqiao.
http://www.emacswiki.org/emacs/XueFuqiao
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: About `read'
[not found] ` <mailman.16693.1357308229.855.help-gnu-emacs@gnu.org>
@ 2013-01-04 16:07 ` Barry Margolin
0 siblings, 0 replies; 4+ messages in thread
From: Barry Margolin @ 2013-01-04 16:07 UTC (permalink / raw)
To: help-gnu-emacs
In article <mailman.16693.1357308229.855.help-gnu-emacs@gnu.org>,
Xue Fuqiao <xfq.free@gmail.com> wrote:
> On Fri, 04 Jan 2013 15:44:16 +0200
> Teemu Likonen <tlikonen@iki.fi> wrote:
>
> > Function READ reads one Lisp expression. In your first example the first
> > expression is a list of two symbols. In the second example the first
> > expression is symbol named "I".
> Thanks, I see.
>
> > a function (call it with no arguments for each character,
> > call it with a char as argument to push a char back)
> When STREAM is a function called with one argument, what does `push a char
> back' mean? Where will the char be pushed?
Read often has to check an extra character beyond the representation of
an object, to detect a delimiter. Since this character isn't actually
part of the object, it has to be made available to the next caller. So
read calls the function again, to "unread" the character.
Where it gets pushed is up to the design of the function.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-04 16:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-04 13:35 About `read' Xue Fuqiao
2013-01-04 13:44 ` Teemu Likonen
2013-01-04 14:03 ` Xue Fuqiao
[not found] ` <mailman.16693.1357308229.855.help-gnu-emacs@gnu.org>
2013-01-04 16:07 ` Barry Margolin
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).