Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

reading string literals

3 views
Skip to first unread message

Patrick Summers

unread,
Oct 18, 1999, 3:00:00 AM10/18/99
to
Hello all,

I am new to LISP, but have still managed to write MOST of my phone list
homework assignment in it. However, I am having one small problem:

I would like to have the user input a persons name, but have it treated as a
string literal. When I use the code
(setq firstname (read)) and the user types: Bill
it returns BILL.

How can I read it in as "Bill" without the user typing the quotes?

I would like a simple Stringread function, which the version of Harlequin
LispWorks I'm using does have (I've seen in the list of errors when I make a
mistake), but I can't find any documentation on how to use it.

Thanks in advance,
Pat Summers


Barry Margolin

unread,
Oct 18, 1999, 3:00:00 AM10/18/99
to
In article <7ug0jd$qut$1...@bgtnsc03.worldnet.att.net>,

Patrick Summers <plsu...@worldnet.att.net> wrote:
>Hello all,
>
>I am new to LISP, but have still managed to write MOST of my phone list
>homework assignment in it. However, I am having one small problem:
>
>I would like to have the user input a persons name, but have it treated as a
>string literal. When I use the code
>(setq firstname (read)) and the user types: Bill
>it returns BILL.
>
>How can I read it in as "Bill" without the user typing the quotes?

Try READ-LINE. This will read a line of input as a string.

--
Barry Margolin, bar...@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

Erik Naggum

unread,
Oct 18, 1999, 3:00:00 AM10/18/99
to
* "Patrick Summers" <plsu...@worldnet.att.net>

| I would like to have the user input a persons name, but have it treated
| as a string literal. When I use the code (setq firstname (read)) and the
| user types: Bill it returns BILL.

READ parses and returns Lisp expressions and data.

| How can I read it in as "Bill" without the user typing the quotes?

well, the user obviously needs to terminate his input with something, and
that something is typically a line terminator, too, which means that
READ-LINE should seem like a fairly typical thing to think of.

| I would like a simple Stringread function, which the version of Harlequin
| LispWorks I'm using does have (I've seen in the list of errors when I make a
| mistake), but I can't find any documentation on how to use it.

the problem with introspective environments is that people who have no
idea what to look for tend to find the strangest things. try a textbook
and make sure you leave your old language backgrounds behind: try to
grasp what the language is giving you, rather than insist on taking what
you think it ought to have.

#:Erik

Erann Gat

unread,
Oct 18, 1999, 3:00:00 AM10/18/99
to
In article <7ug0jd$qut$1...@bgtnsc03.worldnet.att.net>, "Patrick Summers"
<plsu...@worldnet.att.net> wrote:

> Hello all,
>
> I am new to LISP, but have still managed to write MOST of my phone list
> homework assignment in it. However, I am having one small problem:
>

> I would like to have the user input a persons name, but have it treated as a
> string literal. When I use the code
> (setq firstname (read)) and the user types: Bill
> it returns BILL.
>

> How can I read it in as "Bill" without the user typing the quotes?

Use READ-LINE. (Or you can write your own reader function using
READ-CHAR.)

Erann Gat
g...@jpl.nasa.gov

0 new messages