On Sun, 24 Aug 2008, Rob Dixon wrote:

Patrick Dupre wrote:

It is a bit more complex.

I am a perl routine calling a Cpp routine,
I wrote the xs to interface the call.
I wrote the methods (in Cpp) for the Cpp class.
In fact I need to use a Minuit2 class.
One needs to call a function with is written in perl (I had no doubt that
I call perl from Cpp !!)
It looks like that I have to options:

1) It is the class which is called by the perl that is going to call a
subroutine perl (nad I need to compile it to be callable by perl and to be
able the call perl),

2) I compile apart the class which call the perl from the class which
is going to be called by the perl. But this requires one more call:
a Cpp class calling a Cpp class: not very efficient.

The reasons !!
My perl now it a urge program that including plenty of libraries.
The perl subroutine in perl that I need to reuse from Cpp is complex and
a was alot easier to write in perl than in Cpp (and it is easier to
maintain because of the hashes of hashes of hashes ...).
I want to use the MInuit package because it has been ported in perl and
I did not find any package doing such minimization.

I know it is not simple, but it should be doable .

- Your purpose still isn't clear to me, but someone else may understand
something that I haven't seen. I hope so

- There is no public module called anything like Minuit2 or MInuit so I assume
 it is a private one
http://seal.web.cern.ch/seal/snapshot/work-packages/mathlibs/minuit/

- You say in previous messages that you have an XS module written that provides
 functions written in C and callable from Perl
Yes (works fine)
- You want to call subroutines written in Perl from the code of this XS module
Yes and No, in fact the xs file call the class of the name. and it is a
method of the class which is calling the perl routine

- Your plan was to embed a perl engine in the build of this extension
I think so
So please check that the above are correct and then tell me these

- The code to call a Perl subroutine from C is ugly but simple. Did you try that
 and did it work? If not then why not?
For now, I am trying to have my c code compiled a way that it can
call the perl, ie. with the perl option that I mentionned before:
cc -o  -c  `perl -MExtUtils::Embed -e ccopts`
- I have suggested that you read the advice in "perldoc perlcall" and call Perl
 routines that way. Have you tried this? What problems did you get when you
 tried?
I am working with the Extending and Embedding Perl manual with has example


- Please consider publishing your code; ideally your /full/ code, so that we can
 see what you are trying to describe
I am afraid that publishing my code is helpfull without tons of
explanations. In addition, it includes c code and plenty of perl packages.
The only think that I can do is to publish an example.

I am not expecting debugging, it is my job.
My main is to write a Makefile.PL which let me generate the right Makefile
compiling the c code with the perl option (as mentioned previously).

I did try another way of doing but I have not been successful, at least not yet. I will work tomorow more to see how I can solve the problem.

Thank a lot for the comments and the time.

The bottom lines / points / frustrations are this

- I cannot debug your code by guessing at all of the things that might be wrong
 with it. Help me to help you

- Forget about embedding Perl into a Perl extension. All of the necessary code
 to compile and interpret a subroutine call is already there in your process.
 If something isn't working when you try to call a Perl subroutine then it
 isn't because you forgot to embed an additional perl compiler/interpreter into
 a Perl process

- If you have already tried to code a call and it didn't work then you should
 have told us about it. Shame on you

- If you haven't already tried to code such a call then do it now, and invite
 all of the regulars on this list to a big party when it works. I like good
 lemonade and lamb steaks with brown bread and plenty of salad please

- When you've tried what we suggest and it doesn't work, tell us all about it
 and we will tell you what is wrong very soon

- Never ask us for help and then ignore it because the idea doesn't fit with
 your vision. Even if ideas are stupid then we will cheer you for trying them.
 You will never be cheered for not trying things you didn't think would work

Now go and try stuff...

  ... and when you've tried something, please tell us what it was and what
      happened.

Rob


--
---
==========================================================================
 Patrick DUPRÉ                      |   |
 Department of Chemistry            |   |    Phone: (44)-(0)-1904-434384
 The University of York             |   |    Fax:   (44)-(0)-1904-432516
 Heslington                         |   |
 York YO10 5DD  United Kingdom      |   |    email: [EMAIL PROTECTED]
==========================================================================
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/

Reply via email to