elan-language / Documentation

0 stars 0 forks source link

'result' keyword for use in functions #180

Closed richardpawson closed 4 months ago

richardpawson commented 4 months ago

Currently the frame for a new Function contains:

return default

Proposal is to change this (i.e. defaultmay no longer be used without a specified type) to:

return result

where result is a new keyword that defines a variable of the type returned by the function, initialised to the default of that type.

resultmay be set to a new value of the correct type within the function e.g.:

function grade(score Int) as String
  if (score > 35) 
    set result to "Pass"
    else
      set result to "Fail"
  end if
  return result
end function