Call by value? Call by reference?

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Call by value? Call by reference?

Nathan Huesken
Hi,

How are haxe function parameters handled? Call by value or reference?
Is it at all independent of the platform? Can I be sure that my parameter values change in the function or not?

Thanks!
Nathan

--

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

Franco Ponticelli
Objects are always by reference, primitives like Int, Float, Bool, String are by value ... and this is consistent on all platforms as far that I know.

Franco.

On Mon, Aug 3, 2009 at 3:34 PM, Nathan Huesken <[hidden email]> wrote:
Hi,

How are haxe function parameters handled? Call by value or reference?
Is it at all independent of the platform? Can I be sure that my parameter values change in the function or not?

Thanks!
Nathan

--

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

edA-qa mort-ora-y
Franco Ponticelli wrote:
> Objects are always by reference, primitives like Int, Float, Bool,
> String are by value ... and this is consistent on all platforms as far
> that I know.

Is string not actually passed by reference?  I'd assume so.  It is
immutable however.  Likewise Int, Float, Bool are all immutable.

I'd be curious what Array does on all the various platforms, in
particular since on PHP arrays are passed by value* whereas most other
languages they are passed by reference.

Do you know how Dynamic is handled?  Is it always by reference, or does
it truly depend on which type is being passed?

(*technically pass-by-reference with copy-on-write semantics)

--
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

BigTPoker uses haXe and DHLIB
        http://BigTPoker.com/?source=haxe-list

The dis-Emi-A haXe Library
        http://wiki.disemia.com/HaXe
       
A full set of tools, classes, and support facilities aimed at
simplifying and expediting game creation in Flash 9.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


--
haXe - an open source web programming language
http://haxe.org

signature.asc (260 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

jlm@justinfront.net
In reply to this post by Franco Ponticelli
It would be great for haXe to have a byRef and byVal functionality the lack of control over this has always been something that annoyed me in flash... not that I have other languages to judge by.
 
On 3 Aug 2009, at 15:54, Franco Ponticelli wrote:

Objects are always by reference, primitives like Int, Float, Bool, String are by value ... and this is consistent on all platforms as far that I know.

Franco.

On Mon, Aug 3, 2009 at 3:34 PM, Nathan Huesken <[hidden email]> wrote:
Hi,

How are haxe function parameters handled? Call by value or reference?
Is it at all independent of the platform? Can I be sure that my parameter values change in the function or not?

Thanks!
Nathan

--

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

Franco Ponticelli
In reply to this post by edA-qa mort-ora-y
On Mon, Aug 3, 2009 at 4:13 PM, edA-qa mort-ora-y <[hidden email]> wrote:
Franco Ponticelli wrote:
> Objects are always by reference, primitives like Int, Float, Bool,
> String are by value ... and this is consistent on all platforms as far
> that I know.

Is string not actually passed by reference?  I'd assume so.  It is
immutable however.  Likewise Int, Float, Bool are all immutable.

The outcome depends on the platform I guess, but you can treat it as by value.
 
I'd be curious what Array does on all the various platforms, in
particular since on PHP arrays are passed by value* whereas most other
languages they are passed by reference.

Arrays ara objects in haXe even targeting php (there is a wrapper around them). So they are always considered by reference.
 
Do you know how Dynamic is handled?  Is it always by reference, or does
it truly depend on which type is being passed?

Depends on the value passed to it but you can apply the above considerations. Anonymous objects are obviously objects and so passed by reference.
 
(*technically pass-by-reference with copy-on-write semantics)

Right ;)

Franco

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

Franco Ponticelli
In reply to this post by jlm@justinfront.net
On Mon, Aug 3, 2009 at 4:15 PM, Justin Lawerance Mills <[hidden email]> wrote:
It would be great for haXe to have a byRef and byVal functionality the lack of control over this has always been something that annoyed me in flash... not that I have other languages to judge by.

I guess it is not really needed and it is a necessity that in my experience is not that common (this obviously may vary with personal programming experience).
Anyway the workaround to it is just to use a "transport" objects:

function changeInt(param : { value : Int }) {
  param.value++;
}

used this way:

var param = { value : 7 };
changeInt(param);
trace(param.value); // = 8

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

jlm@justinfront.net
I know its not generally needed but I notice quite a few people slip up on arrays in flash, its just a nice language feature I probably read about it when I reading Ruby books or somewhere, I agree its not an essential feature just a nice if a language gives you some control over it.
On 3 Aug 2009, at 16:21, Franco Ponticelli wrote:

On Mon, Aug 3, 2009 at 4:15 PM, Justin Lawerance Mills <[hidden email]> wrote:
It would be great for haXe to have a byRef and byVal functionality the lack of control over this has always been something that annoyed me in flash... not that I have other languages to judge by.

I guess it is not really needed and it is a necessity that in my experience is not that common (this obviously may vary with personal programming experience).
Anyway the workaround to it is just to use a "transport" objects:

function changeInt(param : { value : Int }) {
  param.value++;
}

used this way:

var param = { value : 7 };
changeInt(param);
trace(param.value); // = 8
--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

Nathan Huesken
In reply to this post by Franco Ponticelli
So I wonder, is there a way to have multiple return values in haXe (of non pass-by-reference types)?
Regards,
Nathan

On Mon, Aug 03, 2009 at 03:54:00PM +0100, Franco Ponticelli wrote:

>    Objects are always by reference, primitives like Int, Float, Bool, String
>    are by value ... and this is consistent on all platforms as far that I
>    know.
>
>    Franco.
>
>    On Mon, Aug 3, 2009 at 3:34 PM, Nathan Huesken <[1][hidden email]>
>    wrote:
>
>      Hi,
>
>      How are haxe function parameters handled? Call by value or reference?
>      Is it at all independent of the platform? Can I be sure that my
>      parameter values change in the function or not?
>
>      Thanks!
>      Nathan
>
>      --
>      --
>      haXe - an open source web programming language
>      [2]http://haxe.org
>
> References
>
>    Visible links
>    1. mailto:[hidden email]
>    2. http://haxe.org/

> --
> haXe - an open source web programming language
> http://haxe.org

--

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

Ian Liu Rodrigues
You can always return an array or an object:

function f(x:Float, y:Float) {
    return {x: x*y, y: 2*y}; // this return an object of type {x:Float, y:Float}
}

On Mon, Aug 3, 2009 at 12:58 PM, Nathan Huesken <[hidden email]> wrote:
So I wonder, is there a way to have multiple return values in haXe (of non pass-by-reference types)?
Regards,
Nathan

On Mon, Aug 03, 2009 at 03:54:00PM +0100, Franco Ponticelli wrote:
>    Objects are always by reference, primitives like Int, Float, Bool, String
>    are by value ... and this is consistent on all platforms as far that I
>    know.
>
>    Franco.
>
>    On Mon, Aug 3, 2009 at 3:34 PM, Nathan Huesken <[1][hidden email]>
>    wrote:
>
>      Hi,
>
>      How are haxe function parameters handled? Call by value or reference?
>      Is it at all independent of the platform? Can I be sure that my
>      parameter values change in the function or not?
>
>      Thanks!
>      Nathan
>
>      --
>      --
>      haXe - an open source web programming language
>      [2]http://haxe.org
>
> References
>
>    Visible links
>    1. mailto:[hidden email]
>    2. http://haxe.org/

> --
> haXe - an open source web programming language
> http://haxe.org

--

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

edA-qa mort-ora-y
In reply to this post by Nathan Huesken
Nathan Huesken wrote:
> So I wonder, is there a way to have multiple return values in haXe (of non pass-by-reference types)?
> Regards,

Just use anonymous (or non-anonymous) typedefs:

return { value: 123, another: "happy" };


--
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

BigTPoker uses haXe and DHLIB
        http://BigTPoker.com/?source=haxe-list

The dis-Emi-A haXe Library
        http://wiki.disemia.com/HaXe
       
A full set of tools, classes, and support facilities aimed at
simplifying and expediting game creation in Flash 9.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


--
haXe - an open source web programming language
http://haxe.org

signature.asc (260 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

back2dos
In reply to this post by Franco Ponticelli
on wikipedia.org, it is suggested to be called "call-by-sharing":
http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing
one could say, this is call by value, whereas the value is either a
primitive or an object reference ...

i think, call-by-reference should rather be called "call-by-address" or
something ... because that is what happens in most languages, that
support this ... these languages also allow referencing and
dereferencing ... this comes from the fact, that those languages keep a
machine-oriented approach ... more abstractly, it means that function
manipulates variables and not values ...

as far as i understood, this behaviour is consistent accross all
platforms when using pure haXe ... well, actually i don't know about cpp
... :)

greetz

back2dos

> On Mon, Aug 3, 2009 at 4:13 PM, edA-qa mort-ora-y <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Franco Ponticelli wrote:
>     > Objects are always by reference, primitives like Int, Float, Bool,
>     > String are by value ... and this is consistent on all platforms
>     as far
>     > that I know.
>
>     Is string not actually passed by reference?  I'd assume so.  It is
>     immutable however.  Likewise Int, Float, Bool are all immutable.
>
>
> The outcome depends on the platform I guess, but you can treat it as
> by value.
>  
>
>     I'd be curious what Array does on all the various platforms, in
>     particular since on PHP arrays are passed by value* whereas most other
>     languages they are passed by reference.
>
>
> Arrays ara objects in haXe even targeting php (there is a wrapper
> around them). So they are always considered by reference.
>  
>
>     Do you know how Dynamic is handled?  Is it always by reference, or
>     does
>     it truly depend on which type is being passed?
>
>
> Depends on the value passed to it but you can apply the above
> considerations. Anonymous objects are obviously objects and so passed
> by reference.
>  
>
>     (*technically pass-by-reference with copy-on-write semantics)
>
>
> Right ;)
>
> Franco


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

Benjamin Dasnois
Hello,

I guess passing ByRef is... giving a pointer! :-O That's "exactly" the
same thing (ok not quite "exactly" but almost). Modern languages have
dropped pointers for a good reason, and therefor I think we should try
to drop those ByRef/ByValue choices that some languages provide
(Visual Basic?)

Just my two cents...

On Thu, Aug 6, 2009 at 3:50 PM, Juraj Kirchheim<[hidden email]> wrote:

> on wikipedia.org, it is suggested to be called "call-by-sharing":
> http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing
> one could say, this is call by value, whereas the value is either a
> primitive or an object reference ...
>
> i think, call-by-reference should rather be called "call-by-address" or
> something ... because that is what happens in most languages, that support
> this ... these languages also allow referencing and dereferencing ... this
> comes from the fact, that those languages keep a machine-oriented approach
> ... more abstractly, it means that function manipulates variables and not
> values ...
>
> as far as i understood, this behaviour is consistent accross all platforms
> when using pure haXe ... well, actually i don't know about cpp ... :)
>
> greetz
>
> back2dos
>>
>> On Mon, Aug 3, 2009 at 4:13 PM, edA-qa mort-ora-y <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>    Franco Ponticelli wrote:
>>    > Objects are always by reference, primitives like Int, Float, Bool,
>>    > String are by value ... and this is consistent on all platforms
>>    as far
>>    > that I know.
>>
>>    Is string not actually passed by reference?  I'd assume so.  It is
>>    immutable however.  Likewise Int, Float, Bool are all immutable.
>>
>>
>> The outcome depends on the platform I guess, but you can treat it as by
>> value.
>>
>>    I'd be curious what Array does on all the various platforms, in
>>    particular since on PHP arrays are passed by value* whereas most other
>>    languages they are passed by reference.
>>
>>
>> Arrays ara objects in haXe even targeting php (there is a wrapper around
>> them). So they are always considered by reference.
>>
>>    Do you know how Dynamic is handled?  Is it always by reference, or
>>    does
>>    it truly depend on which type is being passed?
>>
>>
>> Depends on the value passed to it but you can apply the above
>> considerations. Anonymous objects are obviously objects and so passed by
>> reference.
>>
>>    (*technically pass-by-reference with copy-on-write semantics)
>>
>>
>> Right ;)
>>
>> Franco
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>



--
DASNOIS Benjamin
http://www.benjamindasnois.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

edA-qa mort-ora-y
Benjamin Dasnois wrote:
> I guess passing ByRef is... giving a pointer! :-O That's "exactly" the
> same thing (ok not quite "exactly" but almost). Modern languages have
> dropped pointers for a good reason, and therefor I think we should try
> to drop those ByRef/ByValue choices that some languages provide
> (Visual Basic?)

Be attentive to what all of this actually means in the syntactic and
semantic world.

Semantically references and pointers are the same thing.  It is the
address of some object. So when passing this as a parameter it is the
address of the object passed and not a copy of the object.

Syntactically references and pointers differ (in say C). References can
be used without dereferencing, whereas pointers required dereferencing.
Once compiled however the difference is lost.

In this light no language has actually gotten rid of pointers. Some
people even argue that C/C++ has a clearer model since the /type/ of the
object has no influence on how it is passed.  That is, there is no
distinction between a fundamental and non-fundamental type.  I believe
OCaml and other lisp-like languages are also similar.


Adding immutables to the mix just makes it more complicated.  In
haXe/Java it is irrelevant whether a string is passed by value or
reference, since it can't be modified anyway.


--
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

BigTPoker uses haXe and DHLIB
        http://BigTPoker.com/?source=haxe-list

The dis-Emi-A haXe Library
        http://wiki.disemia.com/HaXe
       
A full set of tools, classes, and support facilities aimed at
simplifying and expediting game creation in Flash 9.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


--
haXe - an open source web programming language
http://haxe.org

signature.asc (260 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

Benjamin Dasnois
Yes, indeed I think you're telling the same thing as me : what I meant
is that having to manage wether an args is passed byref or byval is
like when you had to know if you passed a pointer or a value (except
it was way more obvious and in this way maybe it was better!)


On Fri, Aug 7, 2009 at 2:15 PM, edA-qa mort-ora-y<[hidden email]> wrote:

> Benjamin Dasnois wrote:
>> I guess passing ByRef is... giving a pointer! :-O That's "exactly" the
>> same thing (ok not quite "exactly" but almost). Modern languages have
>> dropped pointers for a good reason, and therefor I think we should try
>> to drop those ByRef/ByValue choices that some languages provide
>> (Visual Basic?)
>
> Be attentive to what all of this actually means in the syntactic and
> semantic world.
>
> Semantically references and pointers are the same thing.  It is the
> address of some object. So when passing this as a parameter it is the
> address of the object passed and not a copy of the object.
>
> Syntactically references and pointers differ (in say C). References can
> be used without dereferencing, whereas pointers required dereferencing.
> Once compiled however the difference is lost.
>
> In this light no language has actually gotten rid of pointers. Some
> people even argue that C/C++ has a clearer model since the /type/ of the
> object has no influence on how it is passed.  That is, there is no
> distinction between a fundamental and non-fundamental type.  I believe
> OCaml and other lisp-like languages are also similar.
>
>
> Adding immutables to the mix just makes it more complicated.  In
> haXe/Java it is irrelevant whether a string is passed by value or
> reference, since it can't be modified anyway.
>
>
> --
> edA-qa mort-ora-y
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>
> BigTPoker uses haXe and DHLIB
>        http://BigTPoker.com/?source=haxe-list
>
> The dis-Emi-A haXe Library
>        http://wiki.disemia.com/HaXe
>
> A full set of tools, classes, and support facilities aimed at
> simplifying and expediting game creation in Flash 9.
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Sign: Please digitally sign your emails.
> Encrypt: I'm also happy to receive encrypted mail.
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>



--
DASNOIS Benjamin
http://www.benjamindasnois.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

jlm@justinfront.net
It would be possible to keep the same current rules but maybe add it  
to the static typing as sort optional spec ing.

private function fred( pos: val<List<Float>> )
{
}
private function fred( pos: ref<List<Float>> )
{
}

mostly I can see it just defining if something is deep copyied or  
referenced, I think it can be powerful, but with complex typedef it  
may not always be at the top of a static structure chain.. I guess?  
Would it make sense to have variables that always pointed or always  
only copied, and structures that partially copied and partially  
referenced, well we do that already but choice is automatic by the  
type of type, but control is nice?  Just thinking out loud.

;j


On 8 Aug 2009, at 15:33, Benjamin Dasnois wrote:

> Yes, indeed I think you're telling the same thing as me : what I meant
> is that having to manage wether an args is passed byref or byval is
> like when you had to know if you passed a pointer or a value (except
> it was way more obvious and in this way maybe it was better!)
>
>
> On Fri, Aug 7, 2009 at 2:15 PM, edA-qa mort-ora-y<eda-
> [hidden email]> wrote:
>> Benjamin Dasnois wrote:
>>> I guess passing ByRef is... giving a pointer! :-O That's "exactly"  
>>> the
>>> same thing (ok not quite "exactly" but almost). Modern languages  
>>> have
>>> dropped pointers for a good reason, and therefor I think we should  
>>> try
>>> to drop those ByRef/ByValue choices that some languages provide
>>> (Visual Basic?)
>>
>> Be attentive to what all of this actually means in the syntactic and
>> semantic world.
>>
>> Semantically references and pointers are the same thing.  It is the
>> address of some object. So when passing this as a parameter it is the
>> address of the object passed and not a copy of the object.
>>
>> Syntactically references and pointers differ (in say C). References  
>> can
>> be used without dereferencing, whereas pointers required  
>> dereferencing.
>> Once compiled however the difference is lost.
>>
>> In this light no language has actually gotten rid of pointers. Some
>> people even argue that C/C++ has a clearer model since the /type/  
>> of the
>> object has no influence on how it is passed.  That is, there is no
>> distinction between a fundamental and non-fundamental type.  I  
>> believe
>> OCaml and other lisp-like languages are also similar.
>>
>>
>> Adding immutables to the mix just makes it more complicated.  In
>> haXe/Java it is irrelevant whether a string is passed by value or
>> reference, since it can't be modified anyway.
>>
>>
>> --
>> edA-qa mort-ora-y
>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
>> -- --
>>
>> BigTPoker uses haXe and DHLIB
>>        http://BigTPoker.com/?source=haxe-list
>>
>> The dis-Emi-A haXe Library
>>        http://wiki.disemia.com/HaXe
>>
>> A full set of tools, classes, and support facilities aimed at
>> simplifying and expediting game creation in Flash 9.
>>
>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
>> -- --
>> Sign: Please digitally sign your emails.
>> Encrypt: I'm also happy to receive encrypted mail.
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>
>
>
> --
> DASNOIS Benjamin
> http://www.benjamindasnois.com
>
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

gershon
I like things the way the are in haxe, its more natural, us humans also use garbage collectors, keep phone number references to other humans, and get disposed of ourselves when time comes...

the C way of a using pointers might still be needed for embedded systems, were memory is sparse, but i see no point in using it on modern desktops in a modern language.

I'm very fond of the oop paradigm, in the spirit of "everything is an object", i consider everything thats not as "garbage".
Having said that, i do sometimes keep "references" in the shape of typed uninitialized members in a class, sometimes as Dynamic, which is just a dirty as C's void*...
When time comes, these objects are assigned to, and can pass as arguments to methods "by reference"

Correct me if i'm wrong on this one, but haxe is type-safe, and its possible to check with Std.is() prior to casting a Dynamic, something not possible with C and dereferncing void pointers...

On Sat, Aug 8, 2009 at 6:03 PM, Justin Lawerance Mills <[hidden email]> wrote:
It would be possible to keep the same current rules but maybe add it to the static typing as sort optional spec ing.

private function fred( pos: val<List<Float>> )
{
}
private function fred( pos: ref<List<Float>> )
{
}

mostly I can see it just defining if something is deep copyied or referenced, I think it can be powerful, but with complex typedef it may not always be at the top of a static structure chain.. I guess? Would it make sense to have variables that always pointed or always only copied, and structures that partially copied and partially referenced, well we do that already but choice is automatic by the type of type, but control is nice?  Just thinking out loud.

;j



On 8 Aug 2009, at 15:33, Benjamin Dasnois wrote:

Yes, indeed I think you're telling the same thing as me : what I meant
is that having to manage wether an args is passed byref or byval is
like when you had to know if you passed a pointer or a value (except
it was way more obvious and in this way maybe it was better!)


On Fri, Aug 7, 2009 at 2:15 PM, edA-qa mort-ora-y<eda-[hidden email]> wrote:
Benjamin Dasnois wrote:
I guess passing ByRef is... giving a pointer! :-O That's "exactly" the
same thing (ok not quite "exactly" but almost). Modern languages have
dropped pointers for a good reason, and therefor I think we should try
to drop those ByRef/ByValue choices that some languages provide
(Visual Basic?)

Be attentive to what all of this actually means in the syntactic and
semantic world.

Semantically references and pointers are the same thing.  It is the
address of some object. So when passing this as a parameter it is the
address of the object passed and not a copy of the object.

Syntactically references and pointers differ (in say C). References can
be used without dereferencing, whereas pointers required dereferencing.
Once compiled however the difference is lost.

In this light no language has actually gotten rid of pointers. Some
people even argue that C/C++ has a clearer model since the /type/ of the
object has no influence on how it is passed.  That is, there is no
distinction between a fundamental and non-fundamental type.  I believe
OCaml and other lisp-like languages are also similar.


Adding immutables to the mix just makes it more complicated.  In
haXe/Java it is irrelevant whether a string is passed by value or
reference, since it can't be modified anyway.


--
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

BigTPoker uses haXe and DHLIB
      http://BigTPoker.com/?source=haxe-list

The dis-Emi-A haXe Library
      http://wiki.disemia.com/HaXe

A full set of tools, classes, and support facilities aimed at
simplifying and expediting game creation in Flash 9.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


--
haXe - an open source web programming language
http://haxe.org




--
DASNOIS Benjamin
http://www.benjamindasnois.com

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Call by value? Call by reference?

edA-qa mort-ora-y
gershon wrote:
> Correct me if i'm wrong on this one, but haxe is type-safe, and its
> possible to check with Std.is() prior to casting a Dynamic, something
> not possible with C and dereferncing void pointers...

C++ has the same ability to dynamically check a type via dynamic_cast.

I don't think this would be possible in C since struct's don't have
virtual tables which could possibly identify what they are.

--
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

BigTPoker uses haXe and DHLIB
        http://BigTPoker.com/?source=haxe-list

The dis-Emi-A haXe Library
        http://wiki.disemia.com/HaXe
       
A full set of tools, classes, and support facilities aimed at
simplifying and expediting game creation in Flash 9.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


--
haXe - an open source web programming language
http://haxe.org

signature.asc (260 bytes) Download Attachment