Re: delegate support in euphoria?

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

Thanks! is there a benefit for initializing the sequence with repeat? (the alternative is starting with an empty sequence and appending an element every time) is the data structure (beneath the sequence) a vector, a dynamic array, some kind of tree, or a simple array that is continuously copied?

The advantage of using repeat is that there is only a single allocation made. For relatively small sequences, this probably doesn't make much difference. When appending elements, euphoria may have to make several memory allocations, which can end up being costly. Note that it doesn't just reallocate for every element, as it usually allocates a bit extra to accommodate growth in the sequence.

A euphoria sequence is a contiguous block of memory that contains a few bytes of overhead, for bookkeeping, and the elements of the sequence. If the elements are euphoria integers, then they're simply stored in the sequence's memory. If they are atoms or sequences, then the sequence basically stores a pointer to the actual data (either a double or another sequence).

kobi said...

another question: is there support for 'assert' in the middle of euphoria code. thanks alot, I enjoy euphoria and appreciate your comments and support

There's no special assert function or keyword. However, you could do something like this:

-- code..... 
-- code... 
ifdef DEBUG then 
    if some_value = 0 then 
        crash("failed assertion that some_value != 0 ) -- NB crash() comes from std/error.e 
end ifdef 
-- more regular code 

Then, when you want to run with assertions, you could do:

$ eui -d DEBUG myapp.ex 

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu