comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Compiling IDL code with a C compiler
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Compiling IDL code with a C compiler [message #40145] Mon, 19 July 2004 06:05
cedricl is currently offline  cedricl
Messages: 8
Registered: July 2004
Junior Member
David Fanning <davidf@dfanning.com> wrote
> I guess my point is that if you restrict the user to
> "essentially writing C with IDL syntax" the user might
> as well write the C code. That way, he would know for
> *sure* that it will compile. :-)

Well, I'm writing it first and foremost for myself. Advantages:

- As I've said, I would have a testable IDL version to ensure code
correctness _in case_ I have doubts about my IDL-to-C compiler.

- It would be much more integrated into the IDL code, much faster for
debugging, or small modifications. More portable, too.

- Nothing prevents me from supporting more of IDL's syntax, like the
[:] notation, so that I can write more natural IDL.

Personally, I'd be much more tempted to optimize a routine if I only
had to make a few loops explicit and a few type declarations, than if
I have to start a separate .c file, compile it, debug it, and make an
IDL wrapper.

Perhaps I'm more lazy than your are. They say that it's a quality for
a programmer ;-)

Anyway, you've sown the seeds of doubt in my soul, so I'll meditate it
some more. Thank you!

C�dric
Re: Compiling IDL code with a C compiler [message #40147 is a reply to message #40145] Mon, 19 July 2004 04:59 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Cedric,
You re not the first one with this idea. Unfortunately, we never hear a
success story from the people here in this news group. I would strongly
suggest to drop this thought and enjoy the summer instead. :-)

Cheers
Haje



"Cedric" <cedricl@videotron.ca> wrote in message
news:f09ca592.0407171110.53f3b776@posting.google.com...
> Hi everyone,
>
> I'm interested in writing an IDL-to-C compiler, for optimization
> purposes. To be clear about what I'm talking about, here's what some
> sample IDL code would look like:
>
> ;#COMPILE gcc -O1
> function EvaluateEnergy, field, area
> ; Type Declarations
> ;#field = fltarr(101, 101)
> ;#area = fltarr(101, 101)
> ;#sum = float(0.)
>
> sum = 0
> for x=0, 100 do begin
> for y=0, 100 do begin
> sum = sum + field[x,y] ^ 2 * area[x, y]
> endfor
> endfor
> return, sum
> end
>
> My IDL-to-C (pre)compiler would parse the IDL pro files, looking for
> functions preceded by a ;#COMPILE (aka ~preprocessor directive) and
> would translate the subsequent IDL code into the equivalent C code,
> compiling it with the options specified before. It would then replace
> the body of EvaluateEnergy with the proper external function call, and
> compile it with IDL's normal .compile compiler.
>
> So before I embark on such an endeavor, I decided to write here to get
> some input. Is there anything like that already out there? Is there a
> fundamental flaw in my thinking? Any suggestions, advice?
>
> Thank you,
>
> C�dric
>
> (Note: I'm fully aware that the function of my example should be a
> one-liner; it's for demonstration purposes, and because I intend to do
> a "litteral" IDL-to-C translation at first, and not support IDL's
> numerous notational shortcuts)
Re: Compiling IDL code with a C compiler [message #40152 is a reply to message #40147] Sun, 18 July 2004 08:52 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Cedric writes:

> Besides, if I restrict my support of IDL syntax to a bare minimum (so
> much that the user is essentially writing C with IDL syntax, but
> without having to care about the interfacing), then there really
> doesn't seem to be that much to the "translation" phase.

I guess my point is that if you restrict the user to
"essentially writing C with IDL syntax" the user might
as well write the C code. That way, he would know for
*sure* that it will compile. :-)

Cheers,

David

P.S. Let's just say I'd be curious to meet the user
you have in mind. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Compiling IDL code with a C compiler [message #40153 is a reply to message #40152] Sun, 18 July 2004 08:16 Go to previous message
cedricl is currently offline  cedricl
Messages: 8
Registered: July 2004
Junior Member
David Fanning <davidf@dfanning.com> wrote
> Has anyone pointed out to you that IDL is a weakly typed
> language?

Frankly, I've always had trouble distinguishing between
strong/weak/static/dynamic typing. Looking on the Internet, they say
that C++ is weakly typed, too. How does it create a problem? If you
look at my example, I have type declarations as ""preprocessor
directives"" at the top:

; Type Declarations
;#field = fltarr(101, 101)
;#area = fltarr(101, 101)
;#sum = float(0.)

(I'm thinking of replacing those with ASSERT_TYPE, field, fltarr(101,
101) in the IDL version)

Besides, if I restrict my support of IDL syntax to a bare minimum (so
much that the user is essentially writing C with IDL syntax, but
without having to care about the interfacing), then there really
doesn't seem to be that much to the "translation" phase.

Another advantage of this approach is that the IDL code would still be
compilable directly with .compile, since the preprocessor directives
are commented. So it would be good for testing the correctness of the
code.

> Well, best of luck to you! :-)

Thank you!

Cedric
Re: Compiling IDL code with a C compiler [message #40155 is a reply to message #40153] Sat, 17 July 2004 16:25 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Cedric writes:

> So before I embark on such an endeavor, I decided to write here to get
> some input. Is there anything like that already out there? Is there a
> fundamental flaw in my thinking? Any suggestions, advice?

Has anyone pointed out to you that IDL is a weakly typed
language? Well, best of luck to you! :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: call_external on windows - compaq
Next Topic: Subsetting an array with user defined values

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:44:09 PDT 2025

Total time taken to generate the page: 0.00467 seconds