Re: Euphoria's inconsistent typing

new topic     » goto parent     » topic index » view thread      » older message » newer message
SDPringle said...

Structures do not have to be poking and peeking memory but be aliases for numeric indexing for example:

structure rgb  
    integer red  
    integer green  
    integer blue  
end structure  
  
rgb fgcolor = {0,0,0}  
fgcolor.red = #FE -- means fgcolor[1] = #FE  
fgcolor.green = #3B -- means fgcolor[2] = #38  
fgcolor.blue = #60  
  
sequence s = {0,0,0}  
s[1] = 0 -- okay  
s.red = 0 -- error (must declare s as rgb)  

Shawn you just read my mind on this one. I was thinking in this a bit different:

type rgb 
    integer red 
    integer green 
    integer blue 
end type 

I mean, replacing euphoria's 'type as function' by this.

SDPringle said...

And yes, function definitions ought to have obligatory types. You could always declare Them with object but if you force the user to declare what type it returns he will declare hopefully something.

What about the syntax for function type definition? Maybe something like Basic :o)

function foo () as integer 
  return 123 
end function 

Combining this new kind o type definition and function return declaration could speedup interpretation code and simplify the compiler.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu