Re: Anxiety over 4.0
- Posted by Matt Lewis <matthewwalkerlewis at ?mail.co?> Jun 12, 2008
- 734 views
Bernie Ryan wrote: > > Matt Lewis wrote: > > > > Bernie Ryan wrote: > > > > > > irv mullins wrote: > > > > > > > > > > > However, in looking at some of the new capabilities - such as the > > > > ability > > > > to call functions with varying # of parameters > > > > > > My Motor libraries have been able to do that since Euphoria ver 2.5 > > > > It's not the same thing. We've always been able to pass a sequence that > > was used to contain the parameters. In fact, one of the most commonly > > used built-in functions, printf, does just that. > > > > With 4.0, you can specify default values for parameters, and users can > > omit them. For instance: > > > > }}} <eucode> > > function round( atom number, integer decimal_places = 0 ) > > -- ... > > end function > > ? round( 1.5 ) > > ? round( 1.5, 0 ) > > </eucode> {{{ > > > > In GUI libs, this can be very useful and convenient, when you often don't > > need to specify positions, sizes or styles for controls. A possible > > wxEuphoria based example: > > }}} <eucode> > > function wxFrame( atom parent, sequence title, integer id = -1, > > integer x = -1, integer y = -1, > > integer cx = -1, integer cy = -1, > > integer style = 0 ) > > -- ... > > end function > > frame = wxFrame( 0, "My Frame" ) > > -- or... > > frame = wxFrame( 0, "My Frame", , , , , , wxSOME_STYLE ) > > </eucode> {{{ > > > > Matt: > > Mine was: > > library("somelib.so") > declare("wxFrame","...",s) Yes, but how would you handle default parameters? In any case, the above call would be:
myFrame = f("wxFrame", {0, "My Frame", -1, -1, -1, -1, 0})
Also, that's mainly for calling routines in a shared/dynamic library, isn't it? In eu4.0, you can use default parameters calling native euphoria code. Matt