digitalmars.D - Passing objects to functions
- "Garett Bass" <gtbass studiotekne.com> Jul 17 2004
- "Vathix" <vathixSpamFix dprogramming.com> Jul 17 2004
While readin the documentation on D's ABI, I was puzzled by the following
passage:
Reference Types
D has reference types, but they are implicit.
For example, classes are always referred to
by reference; this means that class instances
can never reside on the stack or be passed
as function parameters.
Does this mean that I cannot pass an object to a function? It seems odd
that functions would be restricted from having class-typed parameters.
Thanks in advance for any information on this topic.
Regards,
Garett Bass
gtbass studiotekne.com
Jul 17 2004
"Garett Bass" <gtbass studiotekne.com> wrote in message news:cdcugg$2094$1 digitaldaemon.com...While readin the documentation on D's ABI, I was puzzled by the following passage: Reference Types D has reference types, but they are implicit. For example, classes are always referred to by reference; this means that class instances can never reside on the stack or be passed as function parameters. Does this mean that I cannot pass an object to a function? It seems odd that functions would be restricted from having class-typed parameters. Thanks in advance for any information on this topic. Regards, Garett Bass gtbass studiotekne.com
It just means the class data itself isn't passed to functions, just a reference is: Object myobject = new Object; // a reference to a new Object. void foo(Object obj) { } foo(myobject); // foo()'s obj is a reference to the same thing myobject refers to.
Jul 17 2004








"Vathix" <vathixSpamFix dprogramming.com>