Re: type or func?!?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hayden McKay wrote [quoting order re-arranged]:

> Juergen Luethje wrote:
>>
>> Salix wrote:
>>
>>> How should I define this routine? Is there any difference?
>>>
>>> Example 1
>>> }}}
<eucode>
>>> type seq8(sequence x)
>>> if length(x)=8 then return 1 else return 0 end if
>>> end type
>>> </eucode>
{{{

>>>
>>> Example 2
>>> }}}
<eucode>
>>> function seq8(sequence x)
>>> if length(x)=8 then return 1 else return 0 end if
>>> end function
>>> </eucode>
{{{

>>
>> Yes, there is a difference, see http://www.rapideuphoria.com/refman_2.htm#43
>>
>> How you should define it depends on how you want to use it.
>> If you *only* want to call it like this:
>>
>> }}}
<eucode>
>> sequence s
>> integer f
>> s = "ABCDEFGH"
>> f = seq8(s)
>> -- or
>> if seq8(s) then ...
>> </eucode>
{{{

>> then it doesn't matter.
>>
>> But if you want to use 'seq8' to declare variables, like
>> }}}
<eucode>
>> seq8 s
>> s = "ABCDEFGH"
>> </eucode>
{{{

>> then you must define seq8 as type.
>
> defining it as a type would probably be is better 'cause you can you
> can use }}}
<eucode> without type_check </eucode>
{{{
 in the top level of your
> prog when you want to turn type checking off. even with type chack turned
> off you can still use }}}
<eucode> bool=seq8(array) </eucode>
{{{


Yes, he can do so. But he can do so anyway, regardles whether his
routine is defied as type or as function. So defining it as type
isn't an advantage in this regard. It's s another point that makes
the difference, as I explained previously.

HTH,
   Juergen

-- 
A: Because it considerably reduces the readability of the text.
Q: Why?
A: Top posting.
Q: What is annoying in e-mail and news?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu