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-23 1:40

>>47-48
I really don't know what to make of this...  It seems like a troll, but I think you're actually genuine, which just makes it depressing.

Here's the example from >>20:
y = 5;' means regular value assignment
but 'y = x;', means changing the reference

And his point was that the "semantics" of the two should be the same.  My point is that they obviously can't be the same.  Hell, it's not even "my" point, it's just common sense.  "5" is a literal and "x" is a variable.  You can't assign to "5" just like you can't assign to "hello world".  It resides int he code segment...  The variable "x" is a storage location on the stack or in the process's global space...  It's data, while "5" is a const that is part of the code segment.  When compiled, you're just going to get two very different things.  They're both going to end up as "MOV" instructions in x86, but one is going to be moving a literal and one is going to be reading a value out of the data segment, and these are completely different things in absolutely every language ever conceived.  A language where literals and variables had the same semantics would be a very fucked up (and probably useless) thing.  Is something about this difficult to understand?

I would guess that >>20 just misspoke.  He didn't really mean that literals and variables should have the same semantics.  He just didn't like the assumption that one copied by value and the other copied by reference.  You, on the other hand, just...  shit...  I don't have any idea.

I personally don't have a problem with that assumption and I don't think anyone who actually knows what they're talking about would have a problem with it, either, because they'd be aware that literals and variables aren't the same thing, so you shouldn't expect them to be handled the same, semantically.  Fuck.

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