[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Please explain this unexpected syntax

Posted on 2009-02-09
7
Medium Priority
?
359 Views
Last Modified: 2013-12-10
I have encountered some TCL code (well, Jacl code really), that has the statements shown below.

I understand that #1 creates a new java Object, having a value of 1.  So far, so good.

What I don't understand is the 2nd statement.  I'm used to seeing

set variableName value

So what is this doing?

set 0 value

and why is this after a dereferenced variable?

If you could explain this, and provide equivalent Jython, it would be greatly appreciated.

Thanks
set params [java::new {java.lang.Object[]} {1}]
$params set 0 [java::field com.ibm.websphere.scheduler.BeanTaskInfo class]

Open in new window

0
Comment
Question by:HonorGod
  • 3
5 Comments
 
LVL 41

Author Comment

by:HonorGod
ID: 23592269
Here's the "equivalent" Jython code...


import com.ibm.websphere.scheduler as sch
 
params = [ sch.BeanTaskInfo ];    # class reference
sigs   = [ 'java.lang.Class' ];   # "Signature" identifying "params" type

Open in new window

0
 
LVL 92

Assisted Solution

by:objects
objects earned 400 total points
ID: 23597268
its setting an element in the array isn't it

0
 
LVL 41

Author Comment

by:HonorGod
ID: 23600171
According to the Tcl documentation, one would use the "array" keyword to define an array.

So, I'm still confused.
array set colorcount {
    red   1
    green 5
    blue  4
    white 9
}

Open in new window

0
 
LVL 15

Accepted Solution

by:
mish33 earned 1600 total points
ID: 23601155
It'a special JACL syntax to manipulate Java arrays:

From http://tcljava.sourceforge.net/docs/TclJava/JavaNewCmd.html:

In this example, we see how to allocate an array of java.lang.String objects. This example also demonstrates Java array object commands and their equivalent Java statements, see the javaArrayObj section for more information.
# This is equivalent to the Java statement.
# String[] arr = new String[2];
set arr [java::new {String[]} {2}]

# Set the values of the array elements.
# This is equivalent to the following Java statements.
# arr[0] = "Hello";
# arr[1] = "World";
$arr set 0 "Hello"
$arr set 1 "World"
0
 
LVL 41

Author Closing Comment

by:HonorGod
ID: 31544546
mish33 was completely correct, so gets most of the points.
objects was first, and partially correct, so get some of the points.

Thanks again folks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question