GLBasic forum

Main forum => GLBasic - en => Topic started by: Slydog on 2011-Aug-31

Title: Default TYPEs for Functions
Post by: Slydog on 2011-Aug-31
I noticed in the latest logfile:
Code (glbasic) Select
// 10.090
   // Compiler:
   //    Can assign types when declaring:
   //      LOCAL foo as Tfoo = bar


Are we closer to be able to use this in FUNCTION parameters for specifying a default for TYPE variables, such as:
Code (glbasic) Select
GLOBAL fontDefault AS TFont
GLOBAL fontHeading AS TFont

FontPrint "Using the default font", 0, 0
FontPrint "This is for a heading", 0, 100, fontHeading

FUNCTION FontPrint: text$, x%, y%, font AS TFont = fontDefault
    ....
ENDFUNCTION


If not, it would be nice to have optional TYPE parameters by using a 'NULL' concept such as:
Code (glbasic) Select
FUNCTION FontPrint: text$, x%, y%, font AS TFont = NULL
    IF font = NULL THEN font = fontDefault
    ....
ENDFUNCTION
Title: Re: Default TYPEs for Functions
Post by: Kitty Hello on 2011-Aug-31
I'll put it on the todo. It's just a c++ compiler error, the GPC already accepts it.