getting and passing a function's CURRENT arg block
[1/5] from: moliad::aei::ca at: 16-Nov-2003 17:02
the subject might be misleading, I'm not sure how to formulate it.
I'm this must have been discussed before.
What I wish to do is propagate my arguments to another func with the same arg template,
including refinements. example:
a: func [arg1 arg2 /option val][
print "yahoo"
]
b: func third :a [
; insert code here
print "yes sir!"
either option [
a arg1 arg2 /option val
][
a arg1 arg2
]
]
now in b I don't want the 'EITHER, cause every other refinement adds a binary amount
of possible combination. The function I have has 13 refinements... 106496 different
combinations..
the function I must "improve" is a native, so I can't just source it and re-implement
it. I really need to add some stuff before it, and then let it do its stuff with all
the refinements as if it had been called directly...
what's the best/fastest course of action?
THANKS IN ADVANCE!
-MAx
[2/5] from: antonr:iinet:au at: 17-Nov-2003 14:14
13 refinements seems excessive to me, but anyway
I know this thorny problem. Which native are you
wrapping?
I suggest building a path to the native.
>From an old thread in June with subject: "Re: problems creating a path",
I grabbed the flag-val function:
flag-val: func [flag val][either flag [val][]]
to-path compose [hello (flag-val none 'there) (flag-val true 'someone)]
;== hello/someone
Let's wrap the layout function as an example:
my-layout: func [
specs
/size pane-size
/offset where
][
do probe compose [
(to-path compose [
layout
(flag-val size 'size)
(flag-val offset 'offset)
]) (reduce [specs])
(flag-val size pane-size)
(flag-val offset where)
]
]
; test
view my-layout [box green] ; no refinements
view my-layout/size [box green] 90x90 ; one refinement
view my-layout/offset [box green] 190x190 ; the other refinement
view my-layout/size/offset [box green] 90x90 190x190 ; both refinements
view my-layout/offset/size [box green] 190x190 90x90 ; order reversed
Anton.
[3/5] from: moliad:aei:ca at: 16-Nov-2003 23:53
> === Original Message >
>
> 13 refinements seems excessive to me, but anyway
> I know this thorny problem. Which native are you
> wrapping?
> I suggest building a path to the native.
Brilliant, I will try it right now and give you feedback.
-MAx
[4/5] from: moliad:aei:ca at: 17-Nov-2003 0:30
Anton,
You've made my day. It works. I was even able to replace the function over itself :-)
This is going to be used withing the Open library manager to map current-dir to the load/read/save/write
functions.
I never would have tought of to-path
Rebol never ceases to amaze me.
-MAx
<Yet again, I'm going to bed less of an idiot than when I woke up.>
[5/5] from: g:santilli:tiscalinet:it at: 17-Nov-2003 10:40
Hi Max,
On Sunday, November 16, 2003, 11:02:05 PM, you wrote:
mac> what's the best/fastest course of action?
I think that Ladislav's SUBFUNC is what you're looking for.
http://www.compkarori.com/vanilla/display/subfunc.r
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/