|
I will be out of the country until Monday, October 21, 2002. Please feel free to contact Joe Blanchette at 800-562-9777. Your message reads: Received: from www.antigua.com (unverified [192.168.1.1]) by www.antigua.com (EMWAC SMTPRS 0.83) with SMTP id <B0000706104@www.antigua.com>; Thu, 10 Oct 2002 15:45:47 -0700 Received: FROM linux.midrange.com BY www.antigua.com ; Thu Oct 10 15:45:45 2002 -0700 Received: from linux.midrange.com (localhost [127.0.0.1]) by linux.midrange.com (8.11.6/8.11.6) with ESMTP id g9AMgt110482; Thu, 10 Oct 2002 17:42:56 -0500 Received: from lithium.nac.net (lithium.nac.net [64.21.52.83]) by linux.midrange.com (8.11.6/8.11.6) with SMTP id g9AMev109974 for <rpg400-l@midrange.com>; Thu, 10 Oct 2002 17:40:57 -0500 Received: (qmail 55905 invoked from network); 10 Oct 2002 22:40:52 -0000 Received: from unknown (HELO pc02) (palestinestudies@64.208.162.169) by smtp-auth.nac.net with SMTP; 10 Oct 2002 22:40:52 -0000 From: "Steve Richter" <srichter@autocoder.com> To: <rpg400-l@midrange.com> Subject: RE: timings II. const varying vs value varying Message-ID: <IJEHLALNMGCHOPOBCOGCCEJBCHAA.srichter@autocoder.com> MIME-Version: 1.0 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 In-Reply-To: <20021009234604.G1765-100000@gateway.klements.com> Importance: Normal content-transfer-encoding: 7bit content-type: text/plain; charset=US-ASCII Sender: rpg400-l-admin@midrange.com Errors-To: rpg400-l-admin@midrange.com X-BeenThere: rpg400-l@midrange.com X-Mailman-Version: 2.0.12 Precedence: bulk Reply-To: rpg400-l@midrange.com List-Unsubscribe: <http://lists.midrange.com/cgi-bin/listinfo/rpg400-l>, <mailto:rpg400-l-request@midrange.com?subject=unsubscribe> List-Id: RPG programming on the AS400 / iSeries <rpg400-l.midrange.com> List-Post: <mailto:rpg400-l@midrange.com> List-Help: <mailto:rpg400-l-request@midrange.com?subject=help> List-Subscribe: <http://lists.midrange.com/cgi-bin/listinfo/rpg400-l>, <mailto:rpg400-l-request@midrange.com?subject=subscribe> List-Archive: <http://archive.midrange.com/rpg400-l/> Date: Thu, 10 Oct 2002 18:46:07 -0400 X-Antirelay: Good relay from local net2 192.168.1.0/24 I agree Scott. To return a varying lgth string the called func could ALLOC the bytes needed and then return a pointer to the allocated varying string data. pGetString b dGetString pi * d pString s * d String s 80 a based( pString ) varying c eval pString = %alloc( %size(String)) c eval String = 'some text to return' c return pString p e Only problem is insuring the returned pointer is %DEALLOC'd. now if a DS could have a constructor, destructor and operator member functions .... :) Steve Richter -----Original Message----- From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com]On Behalf Of Scott Klement Sent: Thursday, October 10, 2002 1:03 AM To: rpg400-l@midrange.com Subject: RE: timings II. const varying vs value varying On Wed, 9 Oct 2002, Steve Richter wrote: > > Its just a hunch of mine. C relies on null term strings so I am speculating > that ILE handles them efficiently. > Yes, I'm familiar with C, since I program in it on Unix machines. Normally, though, when you pass a string in C you pass a pointer. I don't think I've EVER seen a C function that passes a string by value. In fact, it's very difficult to pass a string by value in C. I'm not evern sure that you CAN without using a data structure... Normally you'd do something like this: int myfunc(const char *input, char *output, int size); Which means that the input is a pointer to a null-terminated string, passed as "const" (so you can't change it in the function) the output is also a pointer to a null-terminated string. This would be equivalent to the following RPG prototype: D myfunc PR 10I 0 D input * value options(*string) D output * value options(*string) D size 10I 0 value See? You're passing the strings by pointer, i.e. by reference. So you really can't compare it to a varying field passed by value. To pass by value in C you'd have to do something like: #include <stdio.h> struct stuff { char mystring[32000]; }; int myfunc(struct stuff t) { printf("%s\n", t.mystring); return 0; } int main(void) { struct stuff b; strcpy(b.mystring, "This got passed by value!"); return 0; } So, that's about the same thing as: D myfunc PR 10I 0 D string 32000A value Even though the string is "variable length" (i.e. null-terminated) in C, it still copies all 32000 bytes. So I would expect it to actually be less efficient than the RPG counterpart. I suppose I could write up a benchmark and try it... but this message is already getting long :) At any rate, nobody EVER passes strings by value in C. So, I SERIOUSLY doubt you'd find it more efficient than RPG. _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.