Re: Data structures in the next release

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

I have come to the idea that native Euphoria structs are possible already:


We ought to provide library routines for this kind of thing:

sequence s = struct_assign(TM_HOUR, 5, TM_MIN, 30, TM_SEC, 0) -- sets to 5:30:00 
-- s is {0,30,5} 
s[TM_SEC] is 0.  s[TM_HOUR] is 5. 
s[TM_MIN] = 45 
-- s is {0,45,5} 

I have already written these two routines. If anyone would like them, I wrote these some time ago, and they are tight and tested and they don't require 4.1 (probably would work on 3.1)

I know C style structs are much safer than this. It seems to me, if you could bind the indices to the enumerated list somehow so it is only valid in sequences that contain some special syntax you would get the big type safe advantage of C without all of the c types. But then you might end up with something that is so much like C and you would lose the flexibility of EUPHORIA.

I do not use EUPHORIA except for developing it and for writing short little scripts to do some kind of text processing task. For myself the problem is extrinsic to EUPHORIA: A new cool library comes out for AI and it will be written in C++ or Python or Java. Then you have to write a wrapper for it in order to start using it. Because EUPHORIA is consistently pass by value (virtually) the syntax will be different. So, the wrapper ought to be documented.

If someone writes a wrapper they often neglect the documentation and if it is a thick wrapper the lack of documentation makes the wrapper useless. Sometimes the documentation is incomplete, or wrong. This is only made worse by those who change things but are not prepared to look at all of the pages of the documentation and see what needs to be changed and fix that.

In the end, it is analogous to a natural language. It is useful if people speak it. People speak it if it is useful. Lately I have had no time for Euphoria development. Other activities in my life have grown and there is only so much time in a week.

S Pringle

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


Quick Links

User menu

Not signed in.

Misc Menu