[Gimp-user] procedure overloading in scheme / script-fu



I assumed from the scheme manual that procedure-overloading 
(in the form of different numbers of arguments) was permitted,
since, for example, there are two versions of string->number.
However, I can't seem to get it to work.
Anything special one needs to do to overload?

If you take the following code and run it in the script-fu console, it works;
but replacing all occurrances of "foo2" with "foo" 
gets into an infinite loop (I guess; it never returns, in any case).
Is this just a user-error mistake,
or is there something different needed to overload a procedure definition?
I realize the two arg definition had to appear before the one arg definition
which used it; if the order is wrong I get the wrong # args error,
which makes sense.

(define (foo2 arg1 arg2) (string-append arg1 arg2))
(define (foo arg1) (foo2 arg1 "def"))
(foo "abc")
foo2foo"abcdef"

Thanks,

Gary



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]