|
- define a *varsize array as parameter. - define another parameter that contains the amount of array indexes. - in the procedure I have declared the same array with 32767 dimensions as based, so it won't waste space.
Why are you re-declaring the array based on a pointer?! Why not simply reference the parameter?
In other words, why not make the Search subprocedure work like this? p Search B d Search PI 5U 0 d peCode 5A const dim(32767) d options(*varsize) d peElem 5U 0 const d peArgm 5A const d i S 5U 0 /free for i = 1 to peElem ; if peCode(i) = peArgm ; return i ; endif ; endfor ; return 0 ; /end-free p Search eThat way, you can use CONST to make it clear that the subprocedure doesn't update the array, and you also save a few lines of code, including eliinating unnecessary pointer logic.
I don't understand why you did it the way you did?
I cannot use the array parameter as const (no pointer to const parm possible) or value (*varsize not allowed with value parm).
But... the pointer was unnecessary, so you could make it CONST without a problem. I agree that VALUE doesn't make sense, if you used VALUE it'd make a copy of the array, which would add unnecessary overhead to the routine.
Is there a way to protect the original array other than by copying it? And if I have to copy it locally what is the best way to do so. Using the heap?
You don't have to copy it. But, if you did, you may as well use VALUE and let the compiler do the work.
Am I missing somewhat somewhere?
Yes, you're missing that the pointer logic is unnecessary :)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.