Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #29998 > unrolled thread

Java ScriptEngine with a JavaScript returning what?

Started byDonkey Hottie <donkey@fredriksson.dy.fi>
First post2014-09-16 23:02 +0300
Last post2014-09-17 21:17 +0300
Articles 14 — 4 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Java ScriptEngine with a JavaScript returning what? Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-09-16 23:02 +0300
    Re: Java ScriptEngine with a JavaScript returning what? Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-09-16 18:20 -0400
      (was: Re: Java ScriptEngine with a JavaScript returning what?) Robert Klemme <shortcutter@googlemail.com> - 2014-09-17 08:24 +0200
        Re: Re: Java ScriptEngine with a JavaScript returning what?) "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-09-17 09:48 +0100
          Re: Java ScriptEngine with a JavaScript returning what?) Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-09-17 08:32 -0400
            Re: Java ScriptEngine with a JavaScript returning what?) Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-09-17 20:08 +0300
        Re: (was: Re: Java ScriptEngine with a JavaScript returning what?) Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-09-17 19:56 +0300
          Re: (was: Re: Java ScriptEngine with a JavaScript returning what?) Robert Klemme <shortcutter@googlemail.com> - 2014-09-17 19:35 +0200
      Re: Java ScriptEngine with a JavaScript returning what? Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-09-17 19:58 +0300
      Re: Java ScriptEngine with a JavaScript returning what? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-09-17 18:41 +0100
        Re: Java ScriptEngine with a JavaScript returning what? Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-09-17 13:57 -0400
          Re: Java ScriptEngine with a JavaScript returning what? Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-09-17 21:12 +0300
          Re: Java ScriptEngine with a JavaScript returning what? Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-09-17 21:14 +0300
        Re: Java ScriptEngine with a JavaScript returning what? Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-09-17 21:17 +0300

#29998 — Java ScriptEngine with a JavaScript returning what?

FromDonkey Hottie <donkey@fredriksson.dy.fi>
Date2014-09-16 23:02 +0300
SubjectJava ScriptEngine with a JavaScript returning what?
Message-ID<vjhmeb-ecd.ln1@tempest.fredriksson.dy.fi>
Consider a JavaScript:

    var blah;
    blah;

So what does the Java's

    Object ScriptEngine::eval(String script) return now?

blah is not null? Is it not undefined either? Java has no "undefined"
Object type.

What will happen, what will be returned?

-- 

Don't tell any big lies today.  Small ones can be just as effective.

[toc] | [next] | [standalone]


#29999

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2014-09-16 18:20 -0400
Message-ID<lvad3j$qta$1@dont-email.me>
In reply to#29998
On 9/16/2014 4:02 PM, Donkey Hottie wrote:
>
> Consider a JavaScript:
>
>      var blah;
>      blah;
>
> So what does the Java's
>
>      Object ScriptEngine::eval(String script) return now?
>
> blah is not null? Is it not undefined either? Java has no "undefined"
> Object type.
>
> What will happen, what will be returned?

     null

     (Obtained by a five-minute experiment.  "Five" because I have no
acquaintance with the scripting framework and had to read some doc;
a better-versed person could have obtained the answer more quickly.)

-- 
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#30001 — (was: Re: Java ScriptEngine with a JavaScript returning what?)

FromRobert Klemme <shortcutter@googlemail.com>
Date2014-09-17 08:24 +0200
Subject(was: Re: Java ScriptEngine with a JavaScript returning what?)
Message-ID<c7snodFre99U1@mid.individual.net>
In reply to#29999
On 17.09.2014 00:20, Eric Sosman wrote:
> On 9/16/2014 4:02 PM, Donkey Hottie wrote:
>>
>> Consider a JavaScript:
>>
>>      var blah;
>>      blah;
>>
>> So what does the Java's
>>
>>      Object ScriptEngine::eval(String script) return now?

Btw, "::" is a C++ism that does not exist in Java.  In Java we use a 
single dot there.

>> blah is not null? Is it not undefined either? Java has no "undefined"
>> Object type.
>>
>> What will happen, what will be returned?
>
>      null
>
>      (Obtained by a five-minute experiment.  "Five" because I have no
> acquaintance with the scripting framework and had to read some doc;
> a better-versed person could have obtained the answer more quickly.)

<rant>
I do not understand why people are really asking these type of 
questions.  It is more rewarding and faster, too, to try these things 
out than going to a newsgroup to wait for a reply.

I think it's time again to reference
http://catb.org/~esr/faqs/smart-questions.html
</rant>

Bye

	robert

[toc] | [prev] | [next] | [standalone]


#30003 — Re: Re: Java ScriptEngine with a JavaScript returning what?)

From"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Date2014-09-17 09:48 +0100
SubjectRe: Re: Java ScriptEngine with a JavaScript returning what?)
Message-ID<auqdnew67dIA0YTJnZ2dnUVZ7qmdnZ2d@bt.com>
In reply to#30001
Robert Klemme wrote:

> I do not understand why people are really asking these type of
> questions.  It is more rewarding and faster, too, to try these things
> out than going to a newsgroup to wait for a reply.

But, on the other hand, on the newsgroup you may get an /explanation/, or at 
least a link to one.  Not gonna happen by experiment (whence Science).

    -- chris 

[toc] | [prev] | [next] | [standalone]


#30004 — Re: Java ScriptEngine with a JavaScript returning what?)

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2014-09-17 08:32 -0400
SubjectRe: Java ScriptEngine with a JavaScript returning what?)
Message-ID<lvbv0j$8vn$1@dont-email.me>
In reply to#30003
On 9/17/2014 4:48 AM, Chris Uppal wrote:
> Robert Klemme wrote:
>
>> I do not understand why people are really asking these type of
>> questions.  It is more rewarding and faster, too, to try these things
>> out than going to a newsgroup to wait for a reply.
>
> But, on the other hand, on the newsgroup you may get an /explanation/, or at
> least a link to one.  Not gonna happen by experiment (whence Science).

     There's also the possibility that the result I obtained might
have been specific to the particular script engine (Nashorn), and
might be different from that obtained by other engines.  If the O.P.
had said "I get null; is that by specification or by happenstance?"
that would have been a better question (and would have showed some
evidence of energy on his part).  But ...

     O.P.: It yields `null'.

-- 
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#30007 — Re: Java ScriptEngine with a JavaScript returning what?)

FromDonkey Hottie <donkey@fredriksson.dy.fi>
Date2014-09-17 20:08 +0300
SubjectRe: Java ScriptEngine with a JavaScript returning what?)
Message-ID<3proeb-qra.ln1@tempest.fredriksson.dy.fi>
In reply to#30004
17.09.2014, 15:32, Eric Sosman kirjoitti:
> On 9/17/2014 4:48 AM, Chris Uppal wrote:
>> Robert Klemme wrote:
>>
>>> I do not understand why people are really asking these type of
>>> questions.  It is more rewarding and faster, too, to try these things
>>> out than going to a newsgroup to wait for a reply.
>>
>> But, on the other hand, on the newsgroup you may get an /explanation/,
>> or at
>> least a link to one.  Not gonna happen by experiment (whence Science).
> 
>     There's also the possibility that the result I obtained might
> have been specific to the particular script engine (Nashorn), and
> might be different from that obtained by other engines.  If the O.P.
> had said "I get null; is that by specification or by happenstance?"
> that would have been a better question (and would have showed some
> evidence of energy on his part).  But ...
> 
>     O.P.: It yields `null'.
> 

Indeed I do not use Nashorn, and I do not get a null. I use
'rhino:js:1.7R2', maybe I have to switch it to Nashorn. Thanks for the
pointer, and sad that these things are implementation specific.

-- 

It's lucky you're going so slowly, because you're going in the wrong
direction.

[toc] | [prev] | [next] | [standalone]


#30005 — Re: (was: Re: Java ScriptEngine with a JavaScript returning what?)

FromDonkey Hottie <donkey@fredriksson.dy.fi>
Date2014-09-17 19:56 +0300
SubjectRe: (was: Re: Java ScriptEngine with a JavaScript returning what?)
Message-ID<b3roeb-g68.ln1@tempest.fredriksson.dy.fi>
In reply to#30001
17.09.2014, 09:24, Robert Klemme kirjoitti:
> Btw, "::" is a C++ism that does not exist in Java.  In Java we use a
> single dot there.

I used that, that as I am simulatenously trying to learn new Java 8
features. There do exists :: as a method reference. Not in this context,
but still I though that it might do.

-- 

Good news from afar can bring you a welcome visitor.

[toc] | [prev] | [next] | [standalone]


#30008 — Re: (was: Re: Java ScriptEngine with a JavaScript returning what?)

FromRobert Klemme <shortcutter@googlemail.com>
Date2014-09-17 19:35 +0200
SubjectRe: (was: Re: Java ScriptEngine with a JavaScript returning what?)
Message-ID<c7tv3aF762lU1@mid.individual.net>
In reply to#30005
On 17.09.2014 18:56, Donkey Hottie wrote:
> 17.09.2014, 09:24, Robert Klemme kirjoitti:
>> Btw, "::" is a C++ism that does not exist in Java.  In Java we use a
>> single dot there.
>
> I used that, that as I am simulatenously trying to learn new Java 8
> features. There do exists :: as a method reference. Not in this context,
> but still I though that it might do.

Darn, you're right.  I yet need to work more with Java 8.  I had 
completely forgotten that.  Thanks for the reminder!

Cheers

	robert

[toc] | [prev] | [next] | [standalone]


#30006

FromDonkey Hottie <donkey@fredriksson.dy.fi>
Date2014-09-17 19:58 +0300
Message-ID<47roeb-g68.ln1@tempest.fredriksson.dy.fi>
In reply to#29999
17.09.2014, 01:20, Eric Sosman kirjoitti:
> On 9/16/2014 4:02 PM, Donkey Hottie wrote:
>>
>> Consider a JavaScript:
>>
>>      var blah;
>>      blah;
>>
>> So what does the Java's
>>
>>      Object ScriptEngine::eval(String script) return now?
>>
>> blah is not null? Is it not undefined either? Java has no "undefined"
>> Object type.
>>
>> What will happen, what will be returned?
> 
>     null
> 
>     (Obtained by a five-minute experiment.  "Five" because I have no
> acquaintance with the scripting framework and had to read some doc;
> a better-versed person could have obtained the answer more quickly.)
> 

Actually I tried and experimented with this after I asked, and it
resulted to me that returning  null OR undefined will result as an
Exception, which is unacceptable for my purposes. So I will not return
those values from my script any more. An empty string '' works fine.

-- 

A day for firm decisions!!!!!  Or is it?

[toc] | [prev] | [next] | [standalone]


#30009

From"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Date2014-09-17 18:41 +0100
Message-ID<h4WdnaY_lYfcVYTJnZ2dnUVZ8jidnZ2d@bt.com>
In reply to#29999
Eric Sosman wrote:

> > Consider a JavaScript:
> >
> >      var blah;
> >      blah;
> >
> > So what does the Java's
> >
> >      Object ScriptEngine::eval(String script) return now?
> >
> > blah is not null? Is it not undefined either? Java has no "undefined"
> > Object type.
> >
> > What will happen, what will be returned?
>
>     null

Come to think of it, is that null the result of evaluating

    blah

or is it the result of the last evaluation -- the empty expression following 
the terminating ;  ?

Not sure what JavaScript spec says here, let alone the ScriptEngine's 
interpretation of (presumably "global" variable) 'blah'.

(Asking JavaScript questions on c.l.j.p !  I reel with shame...)

    -- chris 

[toc] | [prev] | [next] | [standalone]


#30010

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2014-09-17 13:57 -0400
Message-ID<lvci2n$rs9$1@dont-email.me>
In reply to#30009
On 9/17/2014 1:41 PM, Chris Uppal wrote:
>[...]
> Come to think of it, is that null the result of evaluating
>
>      blah
>
> or is it the result of the last evaluation -- the empty expression following
> the terminating ;  ?
>
> Not sure what JavaScript spec says here, let alone the ScriptEngine's
> interpretation of (presumably "global" variable) 'blah'.

     FWIW, Nashorn gives null for all of

	var blah; blah;
	var blah; blah
	var blah;
	var blah

> (Asking JavaScript questions on c.l.j.p !  I reel with shame...)

     "Java" is just a familiar shorthand for "JavaScript," right?

-- 
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#30011

FromDonkey Hottie <donkey@fredriksson.dy.fi>
Date2014-09-17 21:12 +0300
Message-ID<1hvoeb-81h.ln1@tempest.fredriksson.dy.fi>
In reply to#30010
17.09.2014, 20:57, Eric Sosman kirjoitti:
> On 9/17/2014 1:41 PM, Chris Uppal wrote:
>> [...]
>> Come to think of it, is that null the result of evaluating
>>
>>      blah
>>
>> or is it the result of the last evaluation -- the empty expression
>> following
>> the terminating ;  ?
>>
>> Not sure what JavaScript spec says here, let alone the ScriptEngine's
>> interpretation of (presumably "global" variable) 'blah'.
> 
>     FWIW, Nashorn gives null for all of
> 
>     var blah; blah;
>     var blah; blah
>     var blah;
>     var blah
> 
>> (Asking JavaScript questions on c.l.j.p !  I reel with shame...)
> 
>     "Java" is just a familiar shorthand for "JavaScript," right?
> 

I debugged my code, and figured out that the wrongdoing was (of course
in my own code). It returned unexpected when it encountered a null
response. Bot in Nashorn and Rhino. Both return a null now for me, and I
am happy.

What is good that I learned about Oracle Nashorn in this process. Thank
You all, you participants ;)

-- 

You'll be called to a post requiring ability in handling groups of people.

[toc] | [prev] | [next] | [standalone]


#30012

FromDonkey Hottie <donkey@fredriksson.dy.fi>
Date2014-09-17 21:14 +0300
Message-ID<plvoeb-81h.ln1@tempest.fredriksson.dy.fi>
In reply to#30010
17.09.2014, 20:57, Eric Sosman kirjoitti:
> On 9/17/2014 1:41 PM, Chris Uppal wrote:
>> [...]
>> Come to think of it, is that null the result of evaluating
>>
>>      blah
>>
>> or is it the result of the last evaluation -- the empty expression
>> following
>> the terminating ;  ?
>>
>> Not sure what JavaScript spec says here, let alone the ScriptEngine's
>> interpretation of (presumably "global" variable) 'blah'.
> 
>     FWIW, Nashorn gives null for all of
> 
>     var blah; blah;
>     var blah; blah
>     var blah;
>     var blah
> 
>> (Asking JavaScript questions on c.l.j.p !  I reel with shame...)
> 
>     "Java" is just a familiar shorthand for "JavaScript," right?
> 

There is no question about that I could mistake Java with Javascript. In
this endeavour, I use JavaScript (or it could jython as well) as a
scripting engine for my app, that allows scripting with what Java has to
offer. Not all configuration can be done with property files in a very
complex system.

-- 

The ripest fruit falls first.
		-- William Shakespeare, "Richard II"

[toc] | [prev] | [next] | [standalone]


#30013

FromDonkey Hottie <donkey@fredriksson.dy.fi>
Date2014-09-17 21:17 +0300
Message-ID<9qvoeb-81h.ln1@tempest.fredriksson.dy.fi>
In reply to#30009
17.09.2014, 20:41, Chris Uppal kirjoitti:
> (Asking JavaScript questions on c.l.j.p !  I reel with shame...)
> 
>     -- chris 

Please take notice, I was asking that "what is this Java library for
JavaScript returning when JavaScript returns "undefined"? As there *is
not such value* in this *beloved* Java".

-- 

You have many friends and very few living enemies.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web