Re: default values of function arguments
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Mar 23, 2000
- 454 views
Hello ©koda, >1. >how can I define default value of argument in function/procedure? >in C it can be done like this,with prototype: func(arg1,arg2=34) >it would be really really useful, so you wouldn't have to write each time >all arguments, but just some. >This would be very useful: >func(arg1,,arg3) >just second argument would then use its default value, third can be >normal(not like in C). > >i know that you can do this: >if arg2=0 then > arg2=34 >end if >or sometin like that, >but is there a better way, quicker? Well, there's NOT a way to do it QUICKER. However, if you are interested in a different way I have devised one. I don't claim that its QUICKER but it is less error prone. myfunc (-- arg#, argvalue {1, 10, 3, 17} ) where the function assumes that arg 2 is 34 >2. >It's dumb that you HAVE to get return value of every function. >Sometimes you need return value, sometimes not, if you dont have time to >check for errors. >Is there a way to use function return values as in C? That's what procedures are for. If a specific function has "side effects" that you want to invoke, you can use this setup: function myfunc () invoke_side_effects.. return optional_return_value end fuction procedure myfuncproc () object junk junk = myfunc () end procedure hope this helps, Lewis Townsend keroltarr at hotmail.com http://geocities.com/keroltarr/ ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com