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

2012-09-19 Thread paynekj
Can you point me to the scheme manual that talks about overloading please.

As you are talking about variable numbers of arguments, this article seems to 
explain how it works:
http://www.math.grin.edu/~stone/courses/scheme/readings/variable-arity.xhtml

And in your example, by replacing foo2 with foo you end up with a second 
definition of foo which replaces the first, and then calls itself recursively 
when used - hence your infinite loop.

-- 
paynekj (via gimpusers.com)
___
gimp-user-list mailing list
gimp-user-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-user-list


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

2012-09-19 Thread Kevin Cozens

On 12-09-18 06:42 PM, Gary Aitken wrote:

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.


Scheme is not an OOP language so it does not support procedure overloading. 
If you look closely, you will see that string-number and number-string can 
take an optional parameter, a radix to use during the conversion. The 
optional radix parameter is not currently supported for either 
string-number or number-string.


Code to add support for the radix was supplied to the TinyScheme project and 
is currently being reviewed so radix support may be added soon to Script-Fu.



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).


If you changed all foo2 to foo, then foo continually calls itself and the 
console will appear to hang.


--
Cheers!

Kevin.

http://www.ve3syb.ca/   |Nerds make the shiny things that distract
Owner of Elecraft K2 #2172  | the mouth-breathers, and that's why we're
| powerful!
#include disclaimer/favourite | --Chris Hardwick
___
gimp-user-list mailing list
gimp-user-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-user-list


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

2012-09-18 Thread Gary Aitken
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)
foo2fooabcdef

Thanks,

Gary
___
gimp-user-list mailing list
gimp-user-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-user-list