Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Everything Is References

Name: Anonymous 2010-08-20 16:29

Is there a language in which variables, function arguments, etc, are always references by default?

For example:

int x = 5;
int y = x;
y++;  // x and y are both 6


If you really did want a copy of something, you'd have to use a keyword:

int x = 5;
int y = copy(x);


And pass-by-value would also have to be done explicitly:

void func(int z)
{
   int w = copy(z); // now w is effectively "local"
}


It would force programmers to at least be aware of the fact that they're making a copy.

Name: Anonymous 2010-08-21 0:22

>>20
which is retarded, as is the concept of reference itself: inflexible syntatic sugar for idiots who don't know how to use something as simple as a pointer. [..] For example, the statement 'y = 5;' means regular value assignment, as expected; but 'y = x;', despite looking much like the previous one, means changing the reference.
That's not true of all programming languages. It's not even true of most languages. In fact that's only true of a certain class of statically typed languages: C, C++, C#, Java, D. And most of those languages don't even have pointers!

In a language like Python, when you type a literal 5, an immutable garbage-collected object is allocated on the heap with value 5. The line "x = 5" assigns the reference 'x' to the newly created object containing 5. The next line "y = x" assigns the reference 'y' to the reference in 'x', which is the same object.

I guess since you don't know that, you shouldn't be in the business of programming.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List