Named return value optimization

Hello,
can anybody tell me wheather sun's CC does named return value
optimization for local variables of classes without copyconstructors?
Objects of classes with copy-constructor don't get optimized as you
can see in the attached example... (function return_indirect)
Is it possible to enable named return value optimization for classes with
copy-constructors?
Note: side effects in copy constructors may be ignored for returning values
says the standard...
Please take a look at the following code, which executes differently
with CC and gcc. (gcc does named return value optimization)
Thanks in advance for your feedback.
Cheers,
Tom
========== file nrvo.cc
#include <iostream>
using namespace std;
struct Int
     Int(void)
     : d(0)
     { cout << "Int::Int(void)" << endl; }
     Int(int i)
     : d(i)
     { cout << "Int::Int(void)" << endl; }
     Int(const Int &i)
     : d(i.d)
     { cout << "Int::Int(const Int &)" << endl; }
     ~Int(void)
     { cout << "Int::~Int(void)" << endl; }
     private:
     int d;
Int return_indirect(void)
     Int i;
     return i;
Int return_direct(void)
     return Int();
int main(void)
     Int i0(return_direct());
     Int i1(return_indirect());
     return 0;
====
gcc output:
Int::Int(void)
Int::Int(void)
Int::~Int(void)
Int::~Int(void)
====
CC output:
Int::Int(void)
Int::Int(void)
Int::Int(const Int &)
Int::~Int(void)
Int::~Int(void)
Int::~Int(void)

Sorry, but I couldn't find bug report/enhance request page for Sun Studio, so I'll write an enhancement request here.
Now I use Sun Studio 11. The C++ compile in it still doesn't have "named return value optimization".
Unfortunately, most of my co-workers don't pay attension how many times (implicit-) copy constructors and destructor are called. So they use temporary object very often to return values.
The optimization might improve our program's performance and memory use(to avoid fragmentation) drastically.
I really need it! I hope that Sun's developer find this topic and improve the C++ compiler in future.

Similar Messages

  • How to get return value from Java runtime.getRuntime.exec?

    I'm running shell commands from an Oracle db (11gr2) on aix.
    But, I would like to get a return value from a shell comand... like you get with "echo $?"
    I use a code like
    CREATE OR REPLACE JAVA SOURCE NAMED common."Host" AS
    import java.io.*;
    public class Host {
      public static int executeCommand(String command) {
        int retval=0;
        try {
            String[] finalCommand;
            finalCommand = new String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
          final Process pr = Runtime.getRuntime().exec(finalCommand);
          pr.waitFor();
       catch (Exception ex) {
          System.out.println(ex.getLocalizedMessage());
          retval=-1;
        return retval;
    /but I do not get a return value... because I don't know how to get return value..
    Edited by: user9158455 on 22-Sep-2010 07:33

    Hi,
    Have your tried pr.exitValue() ?
    I think you also need a finally block that destroys the subprocess
    Regards
    Peter

  • Operations Manager Installation Error - Return Value 3

    Hello, I am having issues installing Operations Manager Reporting 2007 R2. The installation hangs with no status update a little more then midway through. I am receiving the following exception below. I am trying to install this on a named reporting instance.
    013-12-16T16:00:00.0547063-08:00 Debug:
     *** Trace Started ***
    2013-12-16T16:00:00.0859563-08:00 Debug:
    ConfigureOverridesForDWRules: Root Management Server is: CORP32-VS
    2013-12-16T16:30:01.7422063-08:00 Error:
    ConfigureOverridesForDWRules error: System.TimeoutException : The requested operation timed out.
    Exception thrown by custom action:
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.WindowsInstaller.InvalidHandleException: The handle is invalid.
       at Microsoft.WindowsInstaller.SessionProperties.set_Item(String name, String value)
       at Microsoft.Reporting.Setup.ReportingManagedCAs.ConfigureOverridesForDWRules(Session session)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
       at Microsoft.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint)
    CustomAction _ConfigureOverridesForDWRules.9B663534_CD9B_41CC_9D93_4E84D3C5E165 returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
    MSI (s) (1C:FC) [16:30:01:804]: NOTE: custom action _ConfigureOverridesForDWRules.9B663534_CD9B_41CC_9D93_4E84D3C5E165 unexpectedly closed the hInstall handle (type MSIHANDLE) provided to it. The custom action should be fixed to not close that handle.
    Action ended 16:30:01: InstallFinalize. Return value 3.
    MSI (s) (1C:80) [16:30:01:804]: User policy value 'DisableRollback' is 0
    MSI (s) (1C:80) [16:30:01:804]: Machine policy value 'DisableRollback' is 0
    MSI (s) (1C:80) [16:30:01:882]: Executing op: Header(Signature=1397708873,Version=500,Timestamp=1133543036,LangId=1033,Platform=589824,ScriptType=2,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1)
    MSI (s) (1C:80) [16:30:01:882]: Executing op: DialogInfo(Type=0,Argument=1033)
    MSI (s) (1C:80) [16:30:01:882]: Executing op: DialogInfo(Type=1,Argument=System Center Operations Manager 2007 R2 Reporting Server)
    MSI (s) (1C:80) [16:30:01:882]: Executing op: RollbackInfo(,RollbackAction=Rollback,RollbackDescription=Rolling back action:,RollbackTemplate=[1],CleanupAction=RollbackCleanup,CleanupDescription=Removing backup files,CleanupTemplate=File: [1])
    Action 16:30:01: Rollback. Rolling back action:

    Niki,
    I verified the data warehouse SQL server authentication account is indeed blank. I just tried running the installation again and received the following errors in the SQL log.
    12/18/2013 07:43:28,spid177,Unknown,Error 777970008<c/> severity 16<c/> state 1 was raised<c/> but no message with that error number was found in sys.messages. If error is larger than 50000<c/> make sure the user-defined message is
    added using sp_addmessage.
    12/18/2013 07:43:28,spid177,Unknown,Error: 18054<c/> Severity: 16<c/> State: 1.
    12/18/2013 07:43:28,spid88,Unknown,Error 777970008<c/> severity 16<c/> state 1 was raised<c/> but no message with that error number was found in sys.messages. If error is larger than 50000<c/> make sure the user-defined message is added
    using sp_addmessage.
    12/18/2013 07:43:28,spid88,Unknown,Error: 18054<c/> Severity: 16<c/> State: 1.
    12/18/2013 07:43:28,spid173,Unknown,Error 777970008<c/> severity 16<c/> state 1 was raised<c/> but no message with that error number was found in sys.messages. If error is larger than 50000<c/> make sure the user-defined message is added
    using sp_addmessage.
    12/18/2013 07:43:28,spid173,Unknown,Error: 18054<c/> Severity: 16<c/> State: 1.
    12/18/2013 07:43:18,spid173,Unknown,Error 777970008<c/> severity 16<c/> state 1 was raised<c/> but no message with that error number was found in sys.messages. If error is larger than 50000<c/> make sure the user-defined message is added
    using sp_addmessage.
    12/18/2013 07:43:18,spid173,Unknown,Error: 18054<c/> Severity: 16<c/> State: 1.
    12/18/2013 07:43:15,spid13s,Unknown,AppDomain 9702 (OperationsManager.dbo[ddl].9701) unloaded.
    12/18/2013 07:43:14,spid21s,Unknown,AppDomain 9701 (OperationsManager.dbo[ddl].9700) unloaded.
    Also, please see error in the MOMReporting log below:
    2013-12-18T07:41:54.8239565-08:00 Debug: ConfigureOverridesForDWRules: Root Management Server is: COR32
    2013-12-18T08:11:56.1874277-08:00 Error: ConfigureOverridesForDWRules error: System.TimeoutException : The requested operation timed out.
    Exception thrown by custom action:
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.WindowsInstaller.InvalidHandleException: The handle is invalid.
       at Microsoft.WindowsInstaller.SessionProperties.set_Item(String name, String value)
       at Microsoft.Reporting.Setup.ReportingManagedCAs.ConfigureOverridesForDWRules(Session session)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
       at Microsoft.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint)
    CustomAction _ConfigureOverridesForDWRules.9B663534_CD9B_41CC_9D93_4E84D3C5E165 returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
    MSI (s) (38:4C) [08:11:56:281]: NOTE: custom action _ConfigureOverridesForDWRules.9B663534_CD9B_41CC_9D93_4E84D3C5E165 unexpectedly closed the hInstall handle (type MSIHANDLE) provided to it. The custom action should be fixed to not close that handle.
    Action ended 8:11:56: InstallFinalize. Return value 3.
    MSI (s) (38:6C) [08:11:56:359]: User policy value 'DisableRollback' is 0
    MSI (s) (38:6C) [08:11:56:359]: Machine policy value 'DisableRollback' is 0
    MSI (s) (38:6C) [08:11:56:624]: Executing op: Header(Signature=1397708873,Version=500,Timestamp=1133657144,LangId=1033,Platform=589824,ScriptType=2,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1)

  • POPUPKEY_FROM_QUERY returning value to wrong row

    Hi,
    I'm running Apex 3.0.1. I have a tabular report that I'm trying to add a popup from query that returns the key/code value (instead of the display value).
    I can call the pop-up okay, but it's returning the value to the wrong table row. I can see in the naming of the Javascript functions that it's looking at the wrong row. For example, here are 4 rows in display order and the names of the Javascript function calls:
    1. javascript:genList0_f15_1()
    2. javascript:genList0_f15_3()
    3. javascript:genList0_f15_2()
    4. javascript:genList0_f15_0()
    I can see in the function call that it's passing an index that doesn't match the displayed row number here:
    "&p_element_index=" +  escape ('1') + So if I click on the LOV icon for row 1 and select one of the LOV values, it will return the value to the second displayed row (zero-based index).
    I've read here of some issues with not having all rows make the call (e.g. in this post from Patrick Wolf date_popup returning value to wrong row but all my rows have values.
    The tabular report allows sorting by column headers, which I would guess is (at least part of) what's messing the function numbering? The query generates the rows, including the function calls, but the report displays in a different order?
    Any suggestions would be greatly appreciated.
    Thanks,
    Stew
    Good luck,
    Stew
    My Oracle Community blog: http://www.oraclecommunity.net/profiles/blog/list?user=stewstryker

    Christina,
    You hit the nail on the head! The tabular form region was defined as SQL Query - without the Updateable part! I'm not sure why I didn't have it that way from the start...
    Now I just have to find and implement the Javascript that will copy the updated value that's returned by the LOV to the correct column (defined as apex_item.text). That was the only way I could figure how to allow the user to enter a value directly or select from a LOV. Clumsy but functional I believe!
    Thanks to you and Scott for the tips.
    Stew

  • Create SP that returns value and at the same time displays query result in output window

    I would like create an SP which will return the records from the table and also return value to my c# client application.
    For Example:
    Select * from employee returns all the query results in output window.
    Now I want to create an SP
    Create procedure Test
    As
    Declare @ret int,
    Select * from employee
    set @ret = Select count(*) from employee
    if @ret > 0
    return 1
    else
    return 0
    The above algo should return 1 0r 0 to c# client application and at the same time display all employees in sql query output window.
    Can u pls help in this regard.

    The above algo should return 1 0r 0 to c# client application and at the same time display all employees in sql query output window.
    Why?  and No!
    Why?  Your procedure generates a resultset of some number of rows.  You check the resultset for the presence of rows to determine if "anything is there".  You don't need a separate value to tell you this.  Note that it helps
    to post tsql that is syntactically correct.   While we're at it, if you just need to know that rows exist there is no need to count them since that does more work than required.  Simply test for existence using the appropriately-named function
    "exists".  E.g., if exists (select * from dbo.employee). 
    No!  A stored procedure does not display anything anywhere.  The application which executes the procedures is responsible for the consumption of the resultset; it chooses what to do and what to display. 
    Lastly, do not get into the lazy habit of using the asterisk in your tsql code.  That is not best practice.  Along with that, you should also get into the following best practice habits:
    schema-qualify your objects (i.e., dbo.employee)
    terminate every statement - it will eventually be required.

  • UML notation: Class operation return value multiplicity

    Hallo,
    how would you write function from example below using UML notation on implementation level, please:
    class Coin {
      public String[] getSideNames() {
        return new String{ "Odd", "Even" };
    }Multiplicity in return value is troubling me. I've tried +getSideNames( ) : String [ 2 ] but my tool just created new class named "String[2]" :-( To be precise I know that return value of function is array of MyClass with one or more element (1..*) so created class name was "MyClass[1..*]" -- nasty name to pass to javac isn't it? :-)
    Is is possible to write multiplicity of return value this way? I couldn't find anything in omg's "UML: supertructure document" :-( I am not telling that it's not written there :-)))
    Thank You.

    jschell>
    Unfortunately [n] behaves in same fashion as [*] =>
    creating class named MyClass[1..n]" :-(
    duffymo> what's the point?
    this was only sample, real application is far more
    complex than that. Even "nature" of result was just
    made up. How am I or anyone else who responds supposed to know that?
    >
    duffymo> you can have cardinality in a class diagram
    that shows exactly two values are available.
    yup, i ended like that but there's still problem coz
    return value class is "Object[]" :-(Sounds like a bad design, but I haven't seen the code, so I can't tell.
    duffymo> personally, i don't think that exposing the
    side names as ...
    "side names" were just example :-) IMHO there are
    certain situations where one could say "screw the
    abstraction" :-D E.g. for final classes from one
    package that cooperate on single time critical task.
    :)"screw the abstraction" - good luck as an object-oriented designer with that attitude.
    Either you're doing real-time work where time really is critical, or you're just another yutz who is congratulating himself on recognizing a time critical task without doing profiling or getting any real data. (A common mistake.) The maintainence and development time might be more critical here.
    Gotta admit that I'm not much interested in commenting on your poor approximation of the real problem.
    %

  • How to get Shuttle return value?

    Hi All.
    I'm using APEX 4.0. Now I use shuttle item named P2_SCHOOL_INFO, and its list of value is like:
    "Select school_name as display_name ,school_id as return_value from school_info"
    when clicking save button I want to get the return_value in the process.
    I thought I could use it like a collection, so I tried to use it like for i in : P2_SCHOOL_INFO.FIRST..:P2_SCHOOL_INFO.LAST. But it failed.
    How can I get the return value?
    Thanks.

    Hi,
    write down the following code:
    DECLARE
    l_vc_arr    APEX_APPLICATION_GLOBAL.VC_ARR2;
    BEGIN
    l_vc_arr := APEX_UTIL.STRING_TO_TABLE(:P2_SCHOOL_INFO);
    FOR i IN 1..l_vc_arr.count LOOP
    htp.p(l_vc_arr(i)); // you can write down your code to insert into table or display
    END LOOP;
    END;
    Regards,
    Kartik Patel
    http://patelkartik.blogspot.com/
    http://apex.oracle.com/pls/apex/f?p=9904351712:1

  • Inferring return value assignment types - ever seen this ?

    Consider a class designed to hold arbitrary values defined at runtime. It is backed by a Map<String,Object> and values are stored and retrieved by a String identifier. Basic type checking is also performed.
    Setting the values is straightforward: obj.set(name, value) but I have two candidates for syntax of getters.
    First an example of the obvious approach, where getInteger(&hellip;) performs type checking, casting and explicitly returns an Integer:
    Integer id = obj.getInteger("id") ;This is ok but I discovered a more consice syntax that works without without explicitly naming a type nor sacrificing type safety any further:
    Integer id = obj.get("id") ;In this approach we use a generic method, where the return type is inferred and passed to the method. Here's how I do it:
    // root method that is called by both approaches
    private <K> K _get(String name, Class<K> clz) {
      Object value = map.get(name) ;
      // check for null, assignability, etc.
      if (!clz.isAssignableFrom(value.getClass())) {
          throw new RuntimeException(clz + " is not assignable from " + value.getClass()) ;
      return (K) value ;
    // method 1 - the obvious way
    public Integer getInteger(String name) {
      return _get(name, Integer.class) ;
    // method 2
    public <T> T get(String name, T...ts) {
      if (ts.length > 0) throw new RuntimeException("Illegal usage...") ;
      return (T) _get(name, ts.getClass().getComponentType()) ;
    }This works becaues type T is used for both the var-arg array and the return value. Of course, it probably fails if you provide additional args - you're not supposed to. ts.getClass().getComponentType() returns the type you are assigning the return value to.
    Not many languages can take this into consideration. In a way, it makes the return type part of the signature.
    Advantages:
    - Much smaller API
    - Dynamic extension for use with a new datatype doesn't require adding a new getX() method
    - Members can be treated uniformly, such a through iteration
    Disadvantages:
    - Involve the confusing zero-length var-args in the api that must be ignored
    - Type is inferred to be Object when the return value is not assigned
    At first you might think that the method 1 is more type-safe but in fact it is not. Using method 1 you have to align the method with the assignment type, but you can still exception at runtime. In method2 the datatype is simply inferred.
    I'm interested in your thoughts on this teqnique. Please let me know if you have a way of concealing the var-args oddness. I think this technique could complement various patterns quite well, such as factory.
    Thanks for your input.
    Edited by: crackleOK on Jul 21, 2009 4:46 AM

    crackleOK wrote:
    JoachimSauer wrote:
    The only redeeming quality is that it can be very nice to use such code.API's are to use (and often have ugly guts). Unfortunately true, but not a good reason to write ugly implementation code. If you only care about code quality up to the API, then you only care about the shiny coating of your car as well and don't mind the rust as long as you don't see it.
    As I said: sometimes the tradeoff is worth it, but it should still be weighted.
    Also: the ignorable varargs parameters are not needed in any way whatsoever.Please explain.From what I see you can replace this method:
    public <T> T get(String name, T...ts)
    // with
    public <T> T get(String name)without any loss of functionality.

  • Unable to capture return values in web services api

    At the time of login to web services if my server is down ,
    it returns following error :
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
            at java.lang.String.substring(String.java:1438)
            at java.lang.String.substring(String.java:1411)
    I want to capture this error so that i can try another server to login. how do i capture this error
    Another place where i want to capture the return Value is when i look for a report on the server
    rh = boBIPlatform.get("path://InfoObjects/Root Folder/"src_folder"/" + reportName +
                               "@SI_SCHEDULEINFO,SI_PROCESSINFO" ,oGetOptions);
    oInfoObjects = rh.getInfoObjects();
    CrystalReport = (CrystalReport)oInfoObjects.getInfoObject(0);
    Here if the report is not there on the server , it returns a null handler exception.
    but if i try catching it by checking my responsehandler is null  like rh == null  it does not catch it.
    Any help will be appreciated
    thanks
    Rakesh Gupta

    Ted : i have two cases
    1)   server = server_st.nextToken();
        providerURL = "http://"server"/dswsbobje/services";
        sessConnURL = new URL(providerURL + "/session");
       Connection boConnection = new Connection(sessConnURL);
       Session boSession = new Session(boConnection);
      EnterpriseCredential boEnterpriseCredential = new    EnterpriseCredential();
                  boEnterpriseCredential.setLogin(userid);
      boEnterpriseCredential.setPassword(pwd);
      boEnterpriseCredential.setAuthType(auth);
    SessionInfo boSI = boSession.login(boEnterpriseCredential);
    I have got a list of servers running web servcies stored in my tokens. when i pass the first server name say " test:8080" and that server is down , i want to catch somewhere in the code above that it did not get the connection so that i can loop back and try with the second server say test1:8080
    This is for failover purposes.
    at present when i was trying to capture return value of boSI it  breaks giving the error
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1438)
    at java.lang.String.substring(String.java:1411)
    2nd case :
    I am geeting reports from the server and scheduling them:
    i run the following code which works fine if reports is there
    rh = boBIPlatform.get("path://InfoObjects/Root Folder/"src_folder"/" + reportName +
    "@SI_SCHEDULEINFO,SI_PROCESSINFO" ,oGetOptions);
    oInfoObjects = rh.getInfoObjects();
    CrystalReport = (CrystalReport)oInfoObjects.getInfoObject(0);
    Here if  the  report  is not there on the server  then i should be able to catch from the response handle rh that it has got a null value.
    but rh does not return a null value 
    the code ultimately throws a null handle at the following line
    CrystalReport = (CrystalReport)oInfoObjects.getInfoObject(0);
    i am not able to catch the null value there also.
    hope you got my issue.

  • Multiple return values (Bug-ID 4222792)

    I had exactly the same request for the same 3 reasons: strong type safety and code correctness verification at compile-time, code readability and ease of mantenance, performance.
    Here is what Sun replied to me:
    Autoboxing and varargs are provided as part of
    JSRs 14 and 201
    http://jcp.org/en/jsr/detail?id=14
    http://jcp.org/en/jsr/detail?id=201
    See also:
    http://forum.java.sun.com/forum.jsp?forum=316
    http://developer.java.sun.com/developer/earlyAccess/adding_generics/index.html
    Multiple return values is covered by Bug-ID 4222792
    Typically this is done by returning an array.
    http://developer.java.sun.com/developer/bugParade/bugs/4222792.html
    That's exactly the problem: we dynamically create instances of array objects that would better fit well within the operand stack without stressing the garbage collector with temporary Array object instances (and with their backing store: 2 separate allocations that need to be recycled when it is clearly a pollution that the operand stack would clean up more efficiently)
    If you would like to engage in a discussion with the Java Language developers, the Generics forum would be a better place:
    http://forum.java.sun.com/forum.jsp?forum=316
    I know that (my report was already refering to the JSR for language extension) Generics is not what I was refering to (even if a generic could handle multiple return values, it would still be an allocated Object
    instance to pack them, i.e. just less convenient than using a static class for type safety.
    The most common case of multiple return values involve values that have known static datatypes and that should be checked with strong typesafety.
    The simple case that involves returning two ints then will require at least two object instances and will not solve the garbage collection overhead.
    Using a array of variable objects is exactly similar, except that it requires two instances for the components and one instance for the generic array container. Using extra method parameters with Integer, Byte, ... boxing objects is more efficient, but for now the only practical solution (which causes the least pollution in the VM allocator and garbage collector) is to use a custom class to store the return values in a single instance.
    This is not natural, and needlessly complexifies many interfaces.
    So to avoid this pollution, some solutions are used such as packing two ints into a long and returning a long, depacking the long after return (not quite clean but still much faster at run-time for methods that need to be used with high frequencies within the application. In some case, the only way to cut down the overhead is to inline methods within the caller code, and this does not help code maintenance by splitting the implementation into small methods (something that C++ can do very easily, both because it supports native types parameters by reference, and because it also supports inline methods).
    Finally, suppose we don't want to use tricky code, difficult to maintain, then we'll have to use boxing Object types to allow passing arguments by reference. Shamely boxed native types cannot be allocated on the operand stack as local variables, so we need to instanciate these local variables before call, and we loose the capacity to track the cases where these local variables are not really initialized by an effective call to the method that will assign them. This does not help debugging, and is against the concept of a strongly typed language like Java should be:
    Java makes lots of efforts to track uninitialized variables, but has no way to determine if an already instanciated Object instance refered in a local variable has effectively received an effective assignment because only the instanciation is kept. A typical code will then need to be written like this:
    Integer a = null;
    Integer b = null;
    if (some condition) {
    //call.method(a, b, 0, 1, "dummy input arg");
    // the method is supposed to have assigned a value to a and b,
    // but can't if a and b have not been instanciated, so we perform:
    call.method(a = new Integer(), b = new Integer(), 0, 1, "dummy input
    arg");
    // we must suppose that the method has modified (not initialized!)
    the value
    // of a and b instances.
    now.use(a.value(), b.value())
    // are we sure here that a and b have received a value????
    // the code may be detected at run-time (a null exception)
    // or completely undetected (the method() above was called but it
    // forgot to assign a value to its referenced objects a and b, in which
    // case we are calling in fact: now.use(0, 0); with the default values
    // or a and b, assigned when they were instanciated)
    Very tricky... Hard to debug. It would be much simpler if we just used:
    int a;
    int b;
    if (some condition) {
    (a, b) = call.method(0, 1, "dummy input arg");
    now.use(a, b);
    The compiler would immediately detect the case where a and b are in fact not always initialized (possible use bere initialization), and the first invoked call.method() would not have to check if its arguments are not null, it would not compile if it forgets to return two values in some code path...
    There's no need to provide extra boxing objects in the source as well as at run-time, and there's no stress added to the VM allocator or garbage collector simply because return values are only allocated on the perand stack by the caller, directly instanciated within the callee which MUST (checked at compile-time) create such instances by using the return statement to instanciate them, and the caller now just needs to use directly the variables which were referenced before call (here a and b). Clean and mean. And it allows strong typechecking as well (so this is a real help for programmers.
    Note that the signature of the method() above is:
    class call {
    (int, int) method(int, int, String) { ... }
    id est:
    class "call", member name "method", member type "(IILjava.lang.string;)II"
    This last signature means that the method can only be called by returning the value into a pair of variables of type int, or using the return value as a pair of actual arguments for another method call such as:
    call.method(call.method("dummy input arg"), "other dummy input arg")
    This is strongly typed and convenient to write and debug and very efficient at run-time...

    Can anyone give me some real-world examples where
    multiple return values aren't better captured in a
    class that logically groups those values? I can of
    course give hundreds of examples for why it's better
    to capture method arguments as multiple values instead
    of as one "logical object", but whenever I've hankered
    for multiple return values, I end up rethinking my
    strategy and rewriting my code to be better Object
    Oriented.I'd personally say you're usually right. There's almost always a O-O way of avoiding the situation.
    Sometimes though, you really do just want to return "two ints" from a function. There's no logical object you can think of to put them in. So you end up polluting the namespace:
    public class MyUsefulClass {
    public TwoInts calculateSomething(int a, int b, int c) {
    public static class TwoInts {
        //now, do I use two public int fields here, making it
        //in essence a struct?
       //or do I make my two ints private & final, which
       //requires a constructor & two getters?
      //and while I'm at it, is it worth implementing
      //equals(), how about hashCode()? clone()?
      //readResolve() ?
    }The answer to most of the questions for something as simple as "TwoInts" is usually "no: its not worth implementing those methods", but I still have to think about them.
    More to the point, the TwoInts class looks so ugly polluting the top level namespace like that, MyUsefulClass.TwoInts is public, that I don't think I've ever actually created that class. I always find some way to avoid it, even if the workaround is just as ugly.
    For myself, I'd like to see some simple pass-by-value "Tuple" type. My fear is it'd be abused as a way for lazy programmers to avoid creating objects when they should have a logical type for readability & maintainability.
    Anyone who has maintained code where someone has passed in all their arguments as (mutable!) Maps, Collections and/or Arrays and "returned" values by mutating those structures knows what a nightmare it can be. Which I suppose is an argument that cuts both ways: on the one hand you can say: "why add Tuples which would be another easy thing to abuse", on the other: "why not add Tuples, given Arrays and the Collections framework already allow bad programmers to produce unmainable mush. One more feature isn't going to make a difference either way".
    Ho hum.

  • Unable to see function return values in Visual Studio 2013 debugger

    Hi!
    I can't see function return values in
    Microsoft Visual Studio Ultimate 2013
    Version 12.0.31101.00 Update 4
    Microsoft .NET Framework
    Version 4.5.51650
    Installed Version: Ultimate<o:p></o:p>
    as described in  http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/27/seeing-function-return-values-in-the-debugger-in-visual-studio-2013.aspx
    So what can I do to get this functionality back?
    MsdnMezzo

    Hi MsdnMezzo,
    Reference:
    http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/27/seeing-function-return-values-in-the-debugger-in-visual-studio-2013.aspx
    If use the same sample in the above blog provided by you, how about the result? Could you debug it with the same steps? I could debug it in my side using the VS2013.
    So to make sure that whether it is your VS IDE issue, please debug it with this sample, if it works well, I doubt that we would think about your specific project and the debugging steps.
    If so, to really repro this issue, could you share us a sample with one drive? You could upload your project to one drive and share us the downloaded link in your new reply, I will download and repro this issue in my side.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Best way to use return values in a webservices

    Hi all,
    Scenario: We have three web services. What is the best way to do this acitivity or is it possible?
    webservice1
    webservice2
    webservice3
    Call invoke webservice1 & 2 (they need to their work do be done parallely and will return a value eg "string")and call webservices3 with input values as the returned value from webservice 1 & 2.
    Thanks,
    Shashi
    Edited by: Shashi_sr on Sep 17, 2010 1:46 PM

    Hi Shashi,
    The way to achieve your desired functionality is as follows:
    Create a flow activity, and within that flow activity, you will call web services (using an invoke activity) webservice1 and webservice2.
    After the flow activity, you will then use another invoke activity to call the 3rd webservice using the output given by the first 2 webservices.

  • How to handle return values in AppleScript

    Warning: AppleScript newbie on the loose without adult supervision.
    I have an Omnis Studio app that calls an AppleScript that in turn invokes a couple of shell commands. As an aside, I don't believe Omnis Studio can invoke a shell script directly without other complications.
    What I would like to do is capture the return code and/or any stdout from the shell commands in the AppleScript, then pass that result out as a return value from the AppleScript.
    Q1. How does one hold the return values, exit code, stdout, etc. of a shell script in AppleScript?
    Q2. How do I tell AppleScript to pass the results back to the calling routine?
    Examples, links to documentation, etc, will be gratefully accepted.

    There is a whole forum for just Applescript here:
    http://discussions.apple.com/forum.jspa?forumID=724

  • Accessing function's return value

    Hi there. I have created several pl/sql procedures and functions that I can run as standalone programs and I have no problem integrating them into my java code also. However I cannot access the return value of any created function from my java code. The functions appear to execute correctly because when I deliberately enter an invalid select statement I get the errors I expect to get for that instance nad if I enter a valid select statement in the function the program executes correctly but I still cannot access the function's return value. My java code where I execute the pl/sql function is as follows:
    CallableStatement p = cont.conn.prepareCall("{call ? := Hellen.FUNC}");
    p.setString(1, "z006"); //hellen.FUNC = function name
    p.execute();
    How do I access the return value of my function?
    Do I need to get a ResultSet?
    My function is as follows:
    function func
    return varchar
    is tester varchar(4);
    BEGIN
    select cfcc_code into tester from hellen.test1 where test1.cfcc_code = 'A21';
    return tester;
    END;
    Any help will be gratefully received, Joe

    You need to do something like
    p.registerOutParameter(1, java.lang.String);
    p.execute();
    String result = p.getString(1);Cheers, APC

  • Help : Complex parameter and return value in WebService?

    Hi guys
       These days, I publish a WebService, in it there is an
    operation like this:
       List search(List para);
       in this operation, parameter "para" is a java.util.List, which contains many elements, every element is an instance of customizing class "MyItem", I made "MyItem" implements java.io.Serializable interface. Strangely, when I call this operations in my java client,
    I found that I could not get out every element from para in server-side, but para.size() is showing it contains 10 elements in it. The same thing happen to the return value of this operation, in client, I got an instance of java.util.List class as the return value, when I try
    System.out.println(result.get(0)); it output "null", but
    result.size() is 10, I don't know how to explain this
       Does anyone who encounter this issue too?
    I guess it has something to with the Serializable issue ,but I have made every List item serializable, why it looks like this??

    Hi Kevin,
    I answered you by mail some days ago, but just to complete the thread, I am posting the hint also here:
    Custom types should be manually added to the Virtual Interface, so that they can be serialized.
    Best regards,
    Alexander

Maybe you are looking for

  • Acrobat Pro 9 Very very slow to open and close file

    Hi all. I have several pc where they are praticly identical. I got one pc qhere acrobat 9 pro where installed and when I try to open a pdf it get too much time. I already reinstalled it and no effect. When I open a pdf it get 40 - 50 % of cpu and 50

  • Display Hierarchy according to levels

    Hi All, I have Hierarchy which is of five levels. At each level their respective description is also there. When i uploaded it in data manager, It is uploaded correctly according to five levels. But at each levels, all the level descriptions are disp

  • Problem with Digital Out

    I have installed drivers on my Sound Blaster Creative Audigy2 Value. I have digital output pins on my soundblaster , but the tick to ENABLE Digital Output is missing .. How to enable my digital Output ??

  • Darwin streaming server

    I can't find a discussion area dedicated to Quicktime or Darwin Streaming Server technologies, so since I am working on a MacBook Pro I'll put my initial question here... if anyone wants to direct me to a more appropriate forum, please do! The proble

  • Table cast PL/SQL: ORA-00902: invalid datatype

    I m getting PL/SQL: ORA-00902: invalid datatype error in OPEN pPymtCur FOR SELECT * FROM TABLE(CAST( up_gap_tra_reports.myArray AS traArray)); in my package up_gap_tra_reports. CREATE OR REPLACE PACKAGE GAPSDVEL.up_gap_tra_reports AS TYPE traRecord I