Re: Giving fucnction parameters defaults assigned values later

new topic     » goto parent     » topic index » view thread      » older message » newer message
ArthurCrump said...

In Euphoria version 4.05 a parameter default can be a variable which is only assigned a value after the function declaration. For example, the following code works when the function foo is called.

object par_default    -- Currently no value 
-- More coding 
function foo(object mypay=par_default) 
    -- some code 
    return mypar    -- Or something more useful 
end function 
-- More coding 
par_default = 55 
-- More coding 
?foo() 

Can this behaviour be relied upon in future versions? I would like to put my routines before the constants which are used for the default parameter values so that the routine is documented before the constants (using creole).

I don't see any reason why this wouldn't work in the future. Top level stuff can be tricky when relying on things happening across files, because it depends on the order in which things are included. You should even be able to move the declaration of par_default down to the assignment and it should work.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu