GPU Programmer

50 Reputation

3 Badges

14 years, 125 days

MaplePrimes Activity


These are replies submitted by GPU Programmer

@Carl Love 

I have a specific case where I probably need to call the shell, but in general will try to use FileTools

@acer 

See the attached worksheet.

Test0.maple

Test1.maple

 

Download PackageBuild_-_No_Good_2.mw

@acer 

The issue is not how to inline, when I want to inline a computed formula, I rarely have trouble with that.  The issue really is about separate files.

So, my problem is that I want to create a large package, not as large as plots, but similar to that.  The only process I’ve made work, without some issues, is to put all the procedure definitions inside the module definition.  The idea of one 30K line file seemed unworkable, but maybe I rejected that approach too quickly.

Is it a fair interpretation of your advice that I embrace the need for one mega-file to build the package, but that I pull in, on the order of, 100 little files as part of the build process?  Will read and $include be sufficient for this approach … maybe … I’ll experiment …

@dharr 

I have attached two examples.  The first one works, the second one does not.

I think I understand the problem.  It is late binding.  The DistWorkSheet procedure does not bind to Sqr in the context of the module, rather it binds at runtime.  In the case of a package (or really any module) that is intended to be used by a user in another context this means you can pickup the user definition of this symbol instead of the definition local to the package.

Forgive me if I am a little slow to respond, Maple is a hobby thing at this stage of my life.


 

restart

DistWorkSheet := proc (A, B) Sqr(A[1]-B[1])+Sqr(A[2]-B[2]) end proc

proc (A, B) Sqr(A[1]-B[1])+Sqr(A[2]-B[2]) end proc

(1)

"Test:=module()"

"  export Dist"

_local(Sqr)

"  option package;"

NULL

Sqr := proc (A) A*A end proc

 

Dist := eval(DistWorkSheet)

"end module"

_m2276796501088

(2)

eval(Test:-Dist)

proc (A, B) Sqr(A[1]-B[1])+Sqr(A[2]-B[2]) end proc

(3)

Test:-Dist([0, 0], [1, 1])

2*Sqr(-1)

(4)

NULL

``


 

Download PackageBuild_-_No_Good_1.mw
 

restart

"Test:=module()"

"  export Dist"

_local(Sqr)

"  option package;"

``

Sqr := proc (A) A*A end proc

 

Dist := proc (A, B) Sqr(A[1]-B[1])+Sqr(A[2]-B[2]) end proc

"end module"

_m2672464429280

(1)

eval(Test:-Dist)

s=0000026E3BBCB948, invalid component 8,3 of PROC

Error, (in Typesetting:-Typeset) object at address is invalid

 

` `

 

Error, unexpected result from Typesetting

 

Test:-Dist([0, 0], [1, 1])

2

(2)

``

NULL


 

Download PackageBuild_-_Works_2.mw

 

Page 1 of 1