Re: Pass by Reference

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

And I would totally agree with you, but for completely different reasons. I would in fact shout it from the rooftops as one of the BEST IDEAS EVER. Compared to C++ just quietly going wrong, anyway.

But that's not an equivalent comparison. In something like C where you've got a bad pointer, you have no idea what went wrong.

The interpreted version of Euphoria not only knows that something has gone wrong, but it knows what has gone wrong. The program can even provide that information to itself so if could decide how to recover.

One of the problems with Euphoria is that it isn't balanced. It crashes at the drop of a hat (by design), but doesn't offer any good mechanisms to recover from the error.

The thing is, you can recover from those errors. The try/catch mechanism is a great example. I can't imagine why Euphoria doesn't have some equivalent mechanism.

If Euphoria balanced crashing with a powerful recovery mechanism, that would be great.

But it doesn't, which means that unless you write perfect code, it's going to crash.

Similarly, I like the fact that Euphoria offers me a very flexible data structure, so I don't have to resort to malloc and accidentally trashing memory.

But why does so much of the remainder of the language have to remain so inexpressive? Sure, I can implement structures by using a global sequence, and then pass in an index. But Euphoria (as a language) doesn't support that. So I could write:

-- all structures are stored in a global sequence called STRUCT 
STRUCT[myFilter][FREQUENCY] = frequency 

Gah... That's horrible. Once upon a time, I ended up writing my own macro language for Euphoria just so I wouldn't have to write zillions and zillions of indexes.

Or I could write:

procedure set_struct(integer structureNumber, integer attributeIndex, object value) 
    STRUCT[structureNumber][attributeIndex] = value 
end procedure 
 
-- Yay! Now it's even *more* expensive, since it needs a function call! 
set_struct(myFilter, FREQUENCY, frequency) 

A slightly better version might be:

-- put it in a local so it doesn't need so many indexes... 
structure filter = STRUCT[myFilter] 
 
-- work with it normally 
filter[FREQUENCY] = frequency 
 
-- but don't forget to save it back again! 
STRUCT[myFilter] = filter 

which saves me a bit of writing, but is still a hot mess.

It seems to me that Euphoria ends up being a "simple" language, but requires a lot of extra work for what comes "for free" in other languages.

- David

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

Search



Quick Links

User menu

Not signed in.

Misc Menu