BASIC

Author Topic: Default TYPEs for Functions  (Read 1006 times)

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
Default TYPEs for Functions
« 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
 
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Default TYPEs for Functions
« Reply #1 on: 2011-Aug-31 »
I'll put it on the todo. It's just a c++ compiler error, the GPC already accepts it.