Mysterious "SyntaxError: missing name after . operator"

676 views
Skip to first unread message

Giacecco

unread,
Jul 28, 2010, 7:00:11 AM7/28/10
to appenginejs
See the code below. Don't worry too much about what the code does. The
interesting bit is that I get the syntax error above on the line with
the delete() statement! It looks all good to me! Thank you in advance
for any hint...


var firstAvailableShortURL = undefined, numericShortURL;
if (IsGarbageCollectionNecessary()) {
throw new Error("I did not write this bit of code, yet!!!");
} else {
for(;!firstAvailableShortURL;) {
// I create an empty placeholder, so that I can read its id
firstAvailableShortURL = new ShortURL({});
firstAvailableShortURL.put();
// then I calculate the short URL, from the Datastore numeric id
for(numericShortURL = firstAvailableShortURL.key().id();
numericShortURL > MAX_ENCODABLE_NUMBER; numericShortURL %=
MAX_ENCODABLE_NUMBER) {};
firstAvailableShortURL.shortURLNumeric = numericShortURL;
firstAvailableShortURL.shortURL =
NumberToShortString(numericShortURL);
// I found a suitable numericShortURL, now I need to check
// that it has not been used before
if (Retrieve(firstAvailableShortURL.shortURL)) {
// it has been used before, I need to try again!
firstAvailableShortURL.delete();
firstAvailableShortURL = undefined;
}
}
}
return firstAvailableShortURL;

Giacecco

unread,
Jul 28, 2010, 7:04:55 AM7/28/10
to appenginejs
I forgot that you can find the full error at http://drop.io/gxdw9cn

Frederick Polgardy

unread,
Jul 28, 2010, 7:35:06 AM7/28/10
to appen...@googlegroups.com
delete is a reserved word in JavaScript. You have to say:

firstAvailableShortURL['delete']()

to get around this.

--
Science answers questions; philosophy questions answers.

George Moschovitis

unread,
Jul 28, 2010, 9:45:04 AM7/28/10
to appen...@googlegroups.com
in Appengine you should use:

model.remove() 
or
model.DELETE()

instead of

model.delete()

because delete is a reserved word...

-g.

Giacecco

unread,
Jul 28, 2010, 11:39:08 AM7/28/10
to appenginejs
Thank you all

On Jul 28, 2:45 pm, George Moschovitis <george.moschovi...@gmail.com>
wrote:
> in Appengine you should use:
>
> model.remove()
> or
> model.DELETE()
>
> instead of
>
> model.delete()
>
> because delete is a reserved word...
>
> -g.
>
Reply all
Reply to author
Forward
0 new messages