Problem with nrc 2.02

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with nrc 2.02

Patric Bechtel
Hello Mike, hello all,

I've two quite annoying probs with the current NetRexxC compiler:

Sample netrexx file:

options binary strictcase strictargs
[...]
outWriter=FileWriter(outfile)
s=String
[...]
s='test;'id';'name';'count';'CRLF
outWriter.write(char[] s.toCharArray())

the last two lines are translated to:

s=netrexx.lang.Rexx.toString(netrexx.lang.Rexx.toRexx("test;"+id+";"+name+";"+count+";").OpCc(null,CRLF));
outWriter.write(netrexx.lang.Rexx.toRexx(s.toCharArray()).toint());

There are two probs with this code:
1) I cannot access the write(String) method of the FileWriter class. Whatever I try, NetRexx always tries to choose the
int version of the write method. I've never seen that before, but in the IO classes. But maybe anyone has seen a similar
effect too.
2) Concatenating strings via + in Java is a very bad thing; the code would better look like
s=StringBuffer("test").append(id).append(";").append(name).append(";").append(count).append(";").append(CRLF).toString();
This would have two very important advantages: It would have less object creation (each + creates 3 intermediate objects,
as it creates a Stringbuffer, appends one String to another, converts it to String, so we have 6*3=18 garbage objects,
plus a garbage Rexx object. The second advantage would be the fact that the Stringbuffer append method is null capable;
so calling the above thing with a null name wouldn't result in an NPE, which is not very nice in the current
implementation.

But the most annoying thing in the moment is not being able to access this write(String) method.
Could you write a fix for that?

tia

Patric


PGP Public Key Fingerprint: 2636 F26E F523 7D62  4377 D206 7C68 06BB


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>


Reply | Threaded
Open this post in threaded view
|

Re: Problem with nrc 2.02

Patric Bechtel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 6 Feb 2003 08:42:32 +0000, Mike Cowlishaw wrote:

Hello Mike,

>> options binary strictcase strictargs
>> [...]
>> outWriter=FileWriter(outfile)
>> s=String
>> [...]
>> s='test;'id';'name';'count';'CRLF
>> outWriter.write(char[] s.toCharArray())

>The 'write' problem is almost unique in the Java libraries; I think you
>should be able to achieve what you want by using:

>  outWriter.write(String s)

>though I would have expected the code you show to work.

I tried that already. The first version of the code used all variations
of "guessing" NetRexx to use the String version of write, so:

s=String "whatsoever"
outWriter.write(s)

or even

outWriter.write(String s)

didn't work. I only thought it would NOT work around an array, so I
tried the char[] variant, but no go.

>On concatenation; I believe the Javac compiler will use the StringBuffer
>class for concatenating strings -- check the bytecode listing.   Also, you
>can avoid the NetRexx calls there if you make CRLF type String.

phew. I'm really not sure. But even then, the annoyance of getting an NPE
on concating a null String stays...

tia

Patric


PGP Public Key Fingerprint: 2636 F26E F523 7D62  4377 D206 7C68 06BB

-----BEGIN PGP SIGNATURE-----
Version: PGPsdk version 1.7.1 (C) 1997-1999 Network Associates, Inc. and its affiliated companies.

iQA+AwUBPkKcK3xoBrvMu8qQEQKygQCgrgdZVfVDCING5HihZK2i5JnNP/MAl393
pdbvw4c//LvIeI+n4wq39b8=
=8GvR
-----END PGP SIGNATURE-----


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>