MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: MathLink Q: Not working anymore!!

  • Subject: [mg3280] Re: MathLink Q: Not working anymore!!
  • From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
  • Date: 23 Feb 1996 13:08:37 -0600
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: University of Colorado, Boulder
  • Sender: daemon at wri.com

In article <4gbvpc$mqo at dragonfly.wolfram.com>,
Chang-Hyeon Song <song at cs.purdue.edu> wrote:
>----------------
>:Begin:
>:Function:	m2c
>:Pattern:	M2C[exp_]
>:Arguments:	{exp}
>:ArgumentTypes:	{Manual}
>:ReturnType:	Manual
>:End:
>:Evaluate:	Attributes[M2C] = {HoldAll}
>-----------
>
>??M2C says
>
>----------------
>M2C[exp] will convert given mathematica an expression or    
>     a compound expression into a correspoding C program
>
>Attributes[M2C] = {HoldAll}
> 
>M2C[exp_] := 
>  ExternalCall[LinkObject["m2c", 2, 2], 
>   CallPacket[0, {exp}]]
>
>-----------------
>
>Putting the Evalauate line in different line doesn't make any difference.
>Can anybody help?

First of all, the SetAttributes command should precede the definition
of the function.  This doesn't always matter, but sometimes it does.

Second, even with the HoldAll attributes, "exp" is being evaluated when
the body of M2C is evaluated.  Try re-defining M2C as:

	ClearAll[M2C]
	SetAttributes[M2C, HoldAll]
	M2C[exp_] :=
	  ExternalCall[LinkObject[.....],
	    CallPacket[0, {Unevaluated[exp]}]]

This ought to work, but you don't want to have to do that
every time you load the package.  Try using the following line
in your template file:

	:Arguments:	{Unevaluated[exp]}

I'd be curious to know if that causes mprep to generate the correct
code or not.

		Dave Wagner
		Principia Consulting
		(303) 786-8371
		dbwagner at princon.com
		http://www.princon.com/princon


  • Prev by Date: Re: MathLink Q: Not working anymore!!
  • Next by Date: Re: Postscript o/p to file can/t be read by ghostview
  • Previous by thread: Re: MathLink Q: Not working anymore!!
  • Next by thread: non-transparent background