1. default values of function arguments

------=_NextPart_000_001F_01BF94FB.1C2433E0
        charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

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=3D34)
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=3D0 then
    arg2=3D34
end if
or sometin like that,
but is there a better way, quicker?

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?



------=_NextPart_000_001F_01BF94FB.1C2433E0
        charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-2" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3401" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>1.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>how can&nbsp;I define default value of =
argument in=20
function/procedure?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>in&nbsp;C it can be done&nbsp;like =
this,with=20
prototype: func(arg1,arg2=3D34)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>it would be really really useful, so =
you wouldn't=20
have to write each time</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>all arguments, but just =
some.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial size=3D2>This =
would be very=20
useful:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>func(arg1,,arg3)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>just second argument would then use its =
default=20
value, third can be normal(not like in C).</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>i know that you can do =
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>if arg2=3D0 then</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
arg2=3D34</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>end if</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>or sometin like that,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>but is there a better way, =
quicker?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>2.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>It's dumb that you&nbsp;HAVE =
to&nbsp;get return=20
value of every function.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Sometimes you need return value, =
sometimes not, if=20
you dont have time to</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>check for errors.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Is there a way to use function return =
values as in=20
C?</FONT></DIV>
<DIV>&nbsp;</DIV>

------=_NextPart_000_001F_01BF94FB.1C2433E0--

new topic     » topic index » view message » categorize

2. Re: default values of function arguments

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu