forum-msg-id-129057-edit

Original date:2015-11-09 12:13:32 Edited by: petelomax Subject: Re: Euphoria's inconsistent typing

function foo () as integer 
  return 123 
end function 

The compiler will figure that out anyway. I maintain that the correct syntax for this (and more complex cases) is

function foo () 
integer res 
  res = 123 
  return res 
end function 

The problem, as I see it, with an "as xxx" clause is that should your function yield say either some udt or {}, you've got problems explicitly specifying that in an as clause, whereas if you just let the compiler figure it out, it'll do a better job.

Consider also something like:

constant DEBUG = 0 
function foo () 
  if DEBUG then 
    return {1,2,3} 
  end if 
  return 0 
end function 

It is trivial for the compiler to spot the result is always 0 when DEBUG is 0, and ludicrous to attempt to encapsulate that info in an as clause.

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu