Scripting Language

Everything about development and the OpenMW source code.
ezzetabi
Posts: 407
Joined: 03 Feb 2012, 16:52

Re: Scripting Language

Post by ezzetabi »

I said I wanted stop talking about this... but it is stronger than me :(

Java is like C. You are correct.

Code: Select all

public class C {
public void f() {}
}

...
C a;
a.f();
is like*

Code: Select all

struct C {
};

void f(C* th1s) {}

...
struct C a;
f(&a);
In Java the & is implicit in the call and it uses . instead of ->. Java works this way.

Instead in C++ try to write:

Code: Select all

#include <iostream>

void f(int & t) {
  std::cout << &t <<std::endl; }

int main() {
  int a;
  std::cout << &a << std::endl; }
You will see that the address is the same, because references are indistinguishable** from original variable.

Python looks like this last one: see the id(). Yet it works differently, see the x = (1 + x). Python differs from both.
This is the reason of the original message ``It is debatable''.

*Anyone who tries to say that one call is virtual and other it is not will be shot.
**Maybe there is some arcane way to distinguish, but it not obvious.
Yacoby
Posts: 119
Joined: 30 Sep 2011, 09:42

Re: Scripting Language

Post by Yacoby »

*shrug* All I see is that python is very very like what I think Pass by Value is but with some immutable data types. So when in python you create a new instance of x (because x is an number and therefore immutable) creating the new instance isn't reflected outside the function. Java does the same thing.

Anyways. At heart we are probably auguring over the meaning of pass by value and how we perceive everything. So I agree with "It is debatable''.
ezzetabi
Posts: 407
Joined: 03 Feb 2012, 16:52

Re: Scripting Language

Post by ezzetabi »

I finally understood your point of view. It seems we are just seeing things differently. I was thinking in terms of implementations, pointers and such. You were thinking as effects for the programmers...
From the latter point of view Python IS like Java, you can just imagine that the missing id() function returns the address INSIDE the pointer instead of the address of the pointer itself. Oh well, it was an interesting chat anyhow.
Post Reply