Pass By Reference vs. Pass By Value

by shian ⌂, Saturday, September 05, 2020, 21:51 (24 days ago) @ shian

One of the most important aspects of Euphoria 3, among many others, is that Euphoria 3 is passing arguments to routines (procedure, function, type) always By Value.

Under the hood, sequence and floating point numbers are passed By Reference. This, among other aspects, makes Euphoria a very fast and efficient interpreted language.

Now - What's the big deal? BASIC allowing both Pass By Reference and Pass By Value, as well as C and C++... isn't it great that you're able to choose?

The answer is NO.

C and C++ languages are almost low level languages, or let's say - middle level languages, therefore they must include very hard to maintain low level features, such as different ways to pass variables to routines.

High level languages, such as BASIC, should have never allow Pass By Reference to be exist, to begin with!

Pass By Reference saves you few minutes of programming. But maintaining a program takes much more time then writing a program! And... as you could guess: Pass By Reference is the worst nightmare for the maintainer of your program - even if the maintainer is yourself!

Pass By Reference is an invisible feature of the language that completely throwing to the trash the concept of private variables... i.e. Pass By Reference is modifying the variables of the calling routine silently and invisibly - and what would you call it? What scope is it? Private? Local? Global? Export? Import? What??? NO. It's not a scope at all. It is a low level feature that exist in low level languages for a good reason - yet it should NEVER be exist in any high level language.

All I can say is that Pass By Reference is modifying variables invisibly, therefore it leads to lots of bugs when you write the program - and it is a nightmare when you maintain the program, i.e. since it is an almost invisible feature, you must check each variable of each routine to see if: was it passed by reference? or was it passed by value? The highly important concept of private scope is thrown to the trash - that's crazy.

Euphoria 3 is a very high level language, safe, readable and easy to maintain. Low level features such as "Pass By Reference" are the antithesis of readability and maintainability.

P.s. BASIC had to Pass By Value by default and allow Pass By Reference using a very visible and clear syntax... (Euphoria 3 does not need it anyway).

reference, value, function, procedure

Complete thread:

 RSS Feed of thread

powered by my little forum