Re: Noob question on strings.

2008-12-09 Thread Ant

Hi all,

> I think the reader gets confused after your initial "C:\dev\java
> \clojure\clj-repl.bat"
> If you start the repl again and try the string with \\ it works fine.
> Also, when the reader gets confused by the above string, it seems to
> miss the " at the end. If you enter a " by itself it seems to right
> itself:

Yes, thanks, you are all quite right. The reader had got confused
somehow, and was treating the input as an unterminated string. Just
putting a " on its own solved the problem.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Noob question on strings.

2008-12-09 Thread Mark Wutka



On Dec 9, 6:47 am, Ant <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I've just started looking with interest at the language, and have
> decided to port some of my smaller programs and scripts to Clojure as
> a way of getting to know the language. I am stumbling over Strings at
> the moment, as I am trying to read a file. I have tried the following:
>
> user=> "C:\dev\java\clojure\clj-repl.bat"
> ")\n"
> user=> java.lang.Exception: Invalid token: C:
> java.lang.Exception: ReaderError:(8,1) Invalid token: C:
>         at clojure.lang.LispReader.read(LispReader.java:164)
>         at clojure.lang.Repl.main(Repl.java:68)
> Caused by: java.lang.Exception: Invalid token: C:
>         at clojure.lang.LispReader.interpretToken(LispReader.java:266)
>         at clojure.lang.LispReader.read(LispReader.java:156)
>         ... 1 more
>
> OK, so that didn't work. I read the docs on Strings:
>
> Strings - Enclosed in "double quotes". May span multiple lines.
> Standard Java escape characters are supported.
>
> So next I tried, thinking it may be the backslashes that were the
> problem, and needed escaping:
>
>  "C:\\dev\\java\\clojure\\clj-repl.bat"
> "\n"
> user=> java.lang.Exception: Invalid token: C:
> java.lang.Exception: ReaderError:(10,1) Invalid token: C:
>         at clojure.lang.LispReader.read(LispReader.java:164)
>         at clojure.lang.Repl.main(Repl.java:68)
> Caused by: java.lang.Exception: Invalid token: C:
>         at clojure.lang.LispReader.interpretToken(LispReader.java:266)
>         at clojure.lang.LispReader.read(LispReader.java:156)
>         ... 1 more
>
> Same error, and it seems to me that the double quoted string isn't
> being accepted as a string literal. I tried converting the path to
> forward slashes:
>
> java.lang.Exception: No such namespace: C:/dev/java/clojure
> clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:0: No such
> namespace: C:/dev/java/clojure
>         at clojure.lang.Compiler.analyze(Compiler.java:3713)
>         at clojure.lang.Compiler.analyze(Compiler.java:3671)
>         at clojure.lang.Compiler.eval(Compiler.java:3895)
>         at clojure.lang.Repl.main(Repl.java:75)
> Caused by: java.lang.Exception: No such namespace: C:/dev/java/clojure
>         at clojure.lang.Compiler.resolveIn(Compiler.java:3998)
>         at clojure.lang.Compiler.resolve(Compiler.java:3972)
>         at clojure.lang.Compiler.analyzeSymbol(Compiler.java:3955)
>         at clojure.lang.Compiler.analyze(Compiler.java:3686)
>         ... 3 more
>
> So it seems that this isn't being treated as a string at all! It
> thinks that the slashes are denoting a namespace. What am I missing
> here?

I think the reader gets confused after your initial "C:\dev\java
\clojure\clj-repl.bat"
If you start the repl again and try the string with \\ it works fine.
Also, when the reader gets confused by the above string, it seems to
miss the " at the end. If you enter a " by itself it seems to right
itself:

$ java -jar clojure.jar
Clojure
user=> "C:\dev\java\clojure\clj-repl.bat"
java.lang.Exception: Unsupported escape character: \d
java.lang.Exception: ReaderError:(1,1) Unsupported escape character:
\d
at clojure.lang.LispReader.read(LispReader.java:164)
at clojure.lang.Repl.main(Repl.java:68)
 -- snip --
user=> "C:\\dev\\java\\clojure\\clj-repl.bat"
"\n"
user=> java.lang.Exception: Invalid token: C:
java.lang.Exception: ReaderError:(2,1) Invalid token: C:
at clojure.lang.LispReader.read(LispReader.java:164)
at clojure.lang.Repl.main(Repl.java:68)
Caused by: java.lang.Exception: Invalid token: C:
at clojure.lang.LispReader.interpretToken(LispReader.java:266)
at clojure.lang.LispReader.read(LispReader.java:156)
... 1 more
-- snip --
user=> "
" \n"
user=> "C:\\dev\\java\\clojure\\clj-repl.bat"
"C:\\dev\\java\\clojure\\clj-repl.bat"
user=>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Noob question on strings.

2008-12-09 Thread Michael Wood

On Tue, Dec 9, 2008 at 1:47 PM, Ant <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I've just started looking with interest at the language, and have
> decided to port some of my smaller programs and scripts to Clojure as
> a way of getting to know the language. I am stumbling over Strings at
> the moment, as I am trying to read a file. I have tried the following:
>
> user=> "C:\dev\java\clojure\clj-repl.bat"
> ")\n"
> user=> java.lang.Exception: Invalid token: C:
> java.lang.Exception: ReaderError:(8,1) Invalid token: C:
>at clojure.lang.LispReader.read(LispReader.java:164)
>at clojure.lang.Repl.main(Repl.java:68)
> Caused by: java.lang.Exception: Invalid token: C:
>at clojure.lang.LispReader.interpretToken(LispReader.java:266)
>at clojure.lang.LispReader.read(LispReader.java:156)
>... 1 more
[...]
> java.lang.Exception: No such namespace: C:/dev/java/clojure
[...]

It looks like you've got an unterminated string before you start.

e.g.:

$ java -cp clojure.jar clojure.main
Clojure
user=> string-that-does-not-start-with-a-quote"
java.lang.Exception: Unable to resolve symbol:
string-that-does-not-start-with-a-quote in this context
(NO_SOURCE_FILE:0)
user=> "C:\dev\something"
"\n"
user=> java.lang.Exception: Invalid token: C:
user=> java.lang.Exception: Unsupported character: \dev
user=> java.lang.Exception: Unsupported character: \something
user=>

So try restarting the repl.  Or else type a single " and press Enter
and see what you get.  If you don't get something like "\n" printed by
itself with no exceptions, try it again.

-- 
Michael Wood <[EMAIL PROTECTED]>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Noob question on strings.

2008-12-09 Thread Parth Malwankar



On Dec 9, 4:47 pm, Ant <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I've just started looking with interest at the language, and have
> decided to port some of my smaller programs and scripts to Clojure as
> a way of getting to know the language. I am stumbling over Strings at
> the moment, as I am trying to read a file. I have tried the following:
>
> user=> "C:\dev\java\clojure\clj-repl.bat"
> ")\n"
> user=> java.lang.Exception: Invalid token: C:
> java.lang.Exception: ReaderError:(8,1) Invalid token: C:
>         at clojure.lang.LispReader.read(LispReader.java:164)
>         at clojure.lang.Repl.main(Repl.java:68)
> Caused by: java.lang.Exception: Invalid token: C:
>         at clojure.lang.LispReader.interpretToken(LispReader.java:266)
>         at clojure.lang.LispReader.read(LispReader.java:156)
>         ... 1 more
>
> OK, so that didn't work. I read the docs on Strings:
>
> Strings - Enclosed in "double quotes". May span multiple lines.
> Standard Java escape characters are supported.
>
> So next I tried, thinking it may be the backslashes that were the
> problem, and needed escaping:


>
>  "C:\\dev\\java\\clojure\\clj-repl.bat"
> "\n"
> user=> java.lang.Exception: Invalid token: C:

Seems to work for me (on Linux with svn HEAD):

user=>  "C:\\dev\\java\\clojure\\clj-repl.bat"
"C:\\dev\\java\\clojure\\clj-repl.bat"
user=>  "C:/dev/java/clojure/clj-repl.bat"
"C:/dev/java/clojure/clj-repl.bat"
user=> "C:"
"C:"

What release are you using? I am assuming you are on
windows based on the string. Maybe you can try with the
latest svn sources.

Parth


> java.lang.Exception: ReaderError:(10,1) Invalid token: C:
>         at clojure.lang.LispReader.read(LispReader.java:164)
>         at clojure.lang.Repl.main(Repl.java:68)
> Caused by: java.lang.Exception: Invalid token: C:
>         at clojure.lang.LispReader.interpretToken(LispReader.java:266)
>         at clojure.lang.LispReader.read(LispReader.java:156)
>         ... 1 more
>
> Same error, and it seems to me that the double quoted string isn't
> being accepted as a string literal. I tried converting the path to
> forward slashes:
>
> java.lang.Exception: No such namespace: C:/dev/java/clojure
> clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:0: No such
> namespace: C:/dev/java/clojure
>         at clojure.lang.Compiler.analyze(Compiler.java:3713)
>         at clojure.lang.Compiler.analyze(Compiler.java:3671)
>         at clojure.lang.Compiler.eval(Compiler.java:3895)
>         at clojure.lang.Repl.main(Repl.java:75)
> Caused by: java.lang.Exception: No such namespace: C:/dev/java/clojure
>         at clojure.lang.Compiler.resolveIn(Compiler.java:3998)
>         at clojure.lang.Compiler.resolve(Compiler.java:3972)
>         at clojure.lang.Compiler.analyzeSymbol(Compiler.java:3955)
>         at clojure.lang.Compiler.analyze(Compiler.java:3686)
>         ... 3 more
>
> So it seems that this isn't being treated as a string at all! It
> thinks that the slashes are denoting a namespace. What am I missing
> here?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---