Default TYPEs for Functions

Previous topic - Next topic

Slydog

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
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Kitty Hello

I'll put it on the todo. It's just a c++ compiler error, the GPC already accepts it.