Re: GoTo in Java




"Richard" <riplin@xxxxxxxxxxxx> wrote in message
news:1138298486.064822.222920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> If you had the "reverse compile to different language" feature, you
>> could have the example written once, and then reverse compile it.
>
> The problem with that is that you would never wind up with the example
> as 'language x program' but as a 'language y program in x syntax'. The
> way the code is best arranged for one language depends on features of
> that and 'translation' requires 'complete rewrite'. It would require
> that the translator identify idioms.
>
> Cobol:
> OPEN INPUT file
> IF ( File-Status-1 NOT = "0" )
> DISPLAY "Not found"
> ELSE
> PERFORM UNTIL EoF
> READ file
> AT END SET EoF
> NOT AT END
> process
> END READ
> END-PERORM
> CLOSE file
> END-IF
>
> C:
> if ( file = fopen(filename, "r") )
> {
> while ( ( recpoint = fgets(record, recmax, file) ) != NULL )
> { process; }
> fclose(file);
> }
> else
> puts("Not found");
>
> Python:
> try:
> file = open(filename, "r")
> except:
> print "file not found"
> else:
> for record in file:
> process
> file.close()

I was mainly envioning this tool to be used in the OSS circles, rather
than corporate environments. There's a few projects on Sourceforge that I'd
like to contribute to, but they are written in languages that I am not very
familiar with (e.g. C++).

So let's say someone writes a library in GPSS and publishes it as open
source, along with example usage in the documentation. I tell my IDE to
translate it to Java, and get some unreadable mess, so I just forget about
it. Someone else comes along, translates it to FORTRAN, and gets poor but
readable code, fixes it up to use standard FORTRAN idioms, adds that to the
example documentation, and publishes it. Someone else then translates it to
C++. Then I come back, and notice there's a C++ version now. I tell my IDE
to translate it to Java, and get something not too bad. I can clean it up a
bit, and add it to the docs too.

To prevent 20 page documentation for a 20 line block of code, the
comments could themselves be structured (perhaps via XML?) so you could
instruct your IDE to filter out the parts that are not relevant to you.
E.g.:

<comment>
<description>This function returns the sum of its two
argumnents</description>
<exampleUsage lang="GPSS">
....
</exampleUsage>
<exampleUsage lang="FORTRAN">
....
</exampleUsage>
<exampleUsage lang="C++">
....
</exampleUsage>
<exampleUsage lang="Java">
....
</exampleUsage>
</comment>

And your IDE would be set up with rules like "Show me the Java-related
comments. If there aren't any, then show me the C# related comments.
Otherwise, show me to C related comments. Otherwise, C++." Etc.

- Oliver


.



Relevant Pages

  • Re: Tools for web applications
    ... I used JCreator LE, java IDE for windows because, when I add documentation ... And what IDE you suggest? ... you used one already chances are it will understand python too. ... decide which language "feels" right for you. ...
    (comp.lang.python)
  • Re: help a newbie with a IDE/book combination
    ... I already have a couple of newbie books on Python itself, ... for a good IDE to learn Python. ... good documentation), and you'll probably have more clues wrt/ IDE ... choice/usage once you'll know at least the language basics. ...
    (comp.lang.python)
  • Re: Can anyone translate English to Aramaic?
    ... But not the English language generally. ... post the translation at least into Hebrew ... write it in French or German and I'll translate it into English. ... You wear your vast erudition with consummate grace, Mr. Peter T. Daniels. ...
    (sci.lang)
  • Re: Can anyone translate English to Aramaic?
    ... But not the English language generally. ... write it in French or German and I'll translate it into English. ... I can see why Dan ... The people in the movie who don't speak Aramaic speak "Latin." ...
    (sci.lang)
  • Re: The phrase =?ISO-8859-1?Q?=22T=E1im_ar_do_thaobh=22?=
    ... Carpenter, Wainright etc. - it, the language, has existed here, pre- ... culture suited to these islands. ... Taim ciallmhar would translate as 'I exist being intelligent' - 'I ... Christian invaders translated Irish into writing they were very aware ...
    (soc.culture.irish)