Thanks
David
There are numerous ways of doing this; here are two quick ones:
(defun read-number-line ()
(with-open-file (stream "/tmp/foo")
(let ((line (read-line stream)))
(with-input-from-string (stream line)
(loop for num = (read stream nil nil) while num collect num)))))
or
(defun read-number-line ()
(with-open-file (stream "/tmp/foo")
(let ((line (read-line stream)))
(read-from-string (concatenate 'string "(" line ")")))))
Both have serious drawbacks, but I hope you find something useful
in them. Also lookup *READ-EVAL*, READ and PARSE-INTEGER to
find out what you could use. Also, HANDLER-CASE might be useful.
Hell, it's really hard to tell without further information :-)
Regards,
--
Nils Goesche
"Don't ask for whom the <CTRL-G> tolls."
PGP key ID 0x42B32FC9
David
In addition to Nils's suggestions, look into the reader variable
*read-default-float-format* if you have floating-point numbers. Also,
please note that when you use the general reader, any symbol with a
syntax error relative to the Common Lisp syntax, will be returned as a
symbol. It might be a good idea to set up your own readtable to exclude
irrelevant data types, too. Unfortunately, there is no standard way to
avoid interning new symbols. (I wish there were at least some way to
control the reader's willingness to make symbols.)
///
--
In a fight against something, the fight has value, victory has none.
In a fight for something, the fight is a loss, victory merely relief.
> Unfortunately, there is no standard way to avoid interning new
> symbols. (I wish there were at least some way to control the reader's
> willingness to make symbols.)
I've been wondering about this, recently. Maybe one could make a new
package, bind *package* to the new package, read the file in, and
then delete the temporary package again. Would that work? Is
there a better way?
Aargh, I guess it wouldn't work: What if the file contains cl:foo?
Or better: cl::foo
A _bad_ way is to bind *package* to a non-package and hope to catch the
error without the whole system blowing up. This is a Jackass episode.
> In article <a7vfhh$oh42r$2...@ID-125440.news.dfncis.de>, Nils Goesche wrote:
>>
>> Aargh, I guess it wouldn't work: What if the file contains cl:foo?
>
> Or better: cl::foo
Can't you lock packages so that new symbols can't be created in them?
-jon
--
------------------
Jon Allen Boone
ipmo...@delamancha.org
Yes, that would be nice. How? (I don't know any way to do that)
>> Can't you lock packages so that new symbols can't be created in them?
>
> Yes, that would be nice. How? (I don't know any way to do that)
It's probably not portable - I couldn't find anything in the HyperSpec
that mentions this - but CLISP has a function (package-lock ). I imagine
others may too...
> Nils Goesche <car...@cartan.de> writes:
>
>>> Can't you lock packages so that new symbols can't be created in them?
>>
>> Yes, that would be nice. How? (I don't know any way to do that)
>
> It's probably not portable - I couldn't find anything in the HyperSpec
> that mentions this - but CLISP has a function (package-lock ). I imagine
> others may too...
And, now that I've tried to use it, it doesn't do what I thought. :-(
Ok, my bad, next time I'll try it first...