Re: Pass by Reference

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

If one passes a reference to an item to a routine, without actually looking at the receiver's source code, can the coder know if the passed item will be modified or not?

And..?

That's the case with anything else. Without looking at the code you can't tell if a global value is being altered, either. Yet OpenEuphoria allows it. And that's actually the (really dirty) workaround being suggested here.

DerekParnell said...

If a language knows, without a doubt, that a passed item cannot be modified by the called routine, then many optimisation possibilities open up for it.

Yep. The purpose of a language isn't to be optimized, but to be useful.

DerekParnell said...

In general, it is a safer practice to pass by value, and much less costly to maintain programs written this way. The performance of PBR is not generally an issue but in those situations where it is a factor, you can revert to less safe coding practices (using 'global' memory).

IMNSHO, Euphoria is one of the most unsafe languages I've ever coded in.

It crashes on errors... by design.

It took forever for Robert to be convinced that something like crash_routine() even needed to exist.

The core datatype - the sequence - is inherently unsafe. It's trivial to get an index out of bounds error. (I speak from experience!)

I'd argue that Euphoria is unsafe by design.

- David

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

Search



Quick Links

User menu

Not signed in.

Misc Menu