Re: C Struct Support

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

Are those structure definitions like types so that one can declare variables of those types and to transfert data from struct to sequence I expect a simple syntax like:

mem_struct numbers  
	integer(8) byte  
	integer(16) word  
	integer(32) dword  
	integer(64) longlong  
	atom(32) float  
	atom(64) double  
end mem_struct  
 
--numbers is a data type 
numbers a 
--  is not a data type 
atom a 
a=alloc(sizeof(numbers)) 
--or better 
atom a=alloc(numbers) 
-- and for transfert of data between sequence and structure 
a={32,65535,-128000,1386836683, 3.1416, 3.1e100} 
-- if length(sequence) < struct_member_count what append? zero trailing members? 
-- the inverse should be as simple as 
sequence  b=a 

They're not that smart, although I like the assignment idea. Right now, you need to specify the structure that you're using each time you use it. It's like having to cast to the struct every time. It's not ideal, but made the preprocessor easy.

Also, it's somewhat difficult to attach that sort of information. We could track the type of a particular variable, but then that information gets lost if it's an element of a sequence, or passed to another routine as a parameter. We could also attach the information to the value (doubles and sequences have that extra cleanup pointer, where we can put whatever we want), but I'm not sure if that's a good thing or not.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu