Euphoria's inconsistent typing

new topic     » topic index » view thread      » older message » newer message

I see euphoria as an optionally typed language:

--strictly typed variables 
atom a = 1, b = 2 
sequence s = {} 
--can be anything 
object o; 

The type information lets the compiler generate optimised bytecode:

atom a = 1, b = 2 
--here the compiler know ahead of time that a, b and c are numbers, no need to emit bytecode that perform runtime type check! 
atom c = a + b 

Why do we have this kind of type anotation if sequences and functions are always generic? Mixing sequence indexing and function calls in a expression defeats the purpose of type anotation:

function foo() 
  sequence s = {{1},2} 
  return s[2] 
end function 
 
--compiler dont know what foo returns ahead of time 
atom a = 1 + foo() 

Sequences are the main form of data struct representation, so its common to use sequence subscripts everywere.

--Type information have limited advantage something like this is more consistent: 
var a = 1 
var s = {} 

What do you think?

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu