Subj : Re: SpiderMonkey: newline in script important? To : netscape.public.mozilla.jseng From : "Franky Braem" Date : Wed Jan 15 2003 06:00 pm Well I found the answer in a JavaScript reference. A ; is mandatory when using an anonymous function. So the compiler in SpiderMonkey is wrong when it allows anonymous functions only ended with a carriage return after the } Franky. "F. Braem" wrote in message news:ff8a7494.0301132349.384e563f@posting.google.com... > Hi, > > While writing a console program for my wxJS project I found out that > when a newline is not contained in the script, it can cause JavaScript > syntax errors. I've used the following script: > > wxTheApp.onInit = function() > { > dlg = new wxDialog(null, -1, "Test"); > dlg.showModal(); > return false; > } > wxTheApp.mainLoop(); > > My console program reads this script from a file with std::getline > which discards the newlines. When I compile the script I get the > following syntax error on line 0 (because of no newlines): missing ; > before statement. After sometime I found out that I had to place a ; > after } > > When I change the sourcecode of the console program as follows: after > each std::getline I add "\r\n". When I compile the script everything > works fine. > > Which of the above is the correct situation? Do I have to place a ; > after setting a function ? Are newlines important in the JavaScript > syntax? > > Franky. > > PS. I'm using SpiderMonkey version 1.5 pre-release 4a 2002-03-21 .