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

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 932
  • 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

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

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10746
  • here on my island the sea says 'hello'
    • View Profile
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.