From wdunlap at tibco.com  Tue Mar  6 01:35:32 2012
From: wdunlap at tibco.com (William Dunlap)
Date: Tue, 6 Mar 2012 00:35:32 +0000
Subject: [Rd] Julia
In-Reply-To: <4F555343.8020007@fhcrc.org>
References: <CAO7JsnRykFo22Jc+pTGsZhg9EvFE=zxE3XpVvSnzc-=mp=AfKw@mail.gmail.com>
	<20120303011413.GA18995@siouxsie>
	<E66794E69CFDE04D9A70842786030B93282DF1@PA-MBX04.na.tibco.com>
	<20120305170835.GA4134@siouxsie> <4F555343.8020007@fhcrc.org>
Message-ID: <E66794E69CFDE04D9A70842786030B932831A9@PA-MBX04.na.tibco.com>

Yes, C does use call by value, always.  However, data arrays
are almost always passed via pointers to malloc'ed space,
so, effectively, data arrays are passed by reference.
(One can put a 'const type*' in the prototype of a function to declare
that the data pointed to will not not be changed, but it is
up to documentation or coding standards to let someone know that
data pointed to will likely be changed.)

I find R's (& S+'s & S's) copy-on-write-if-not-copying-would-be-discoverable-
by-the-uer machanism for giving the allusion of pass-by-value a good way
to structure the contract between the function writer and the function user.
Does Julia have the tools to let a function writer or user decide whether
he really needs to copy its arguments or not?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> -----Original Message-----
> From: r-devel-bounces at r-project.org [mailto:r-devel-bounces at r-project.org] On Behalf Of Herv? Pag?s
> Sent: Monday, March 05, 2012 3:59 PM
> To: oliver
> Cc: R-devel
> Subject: Re: [Rd] Julia
> 
> Hi Oliver,
> 
> On 03/05/2012 09:08 AM, oliver wrote:
> > On Mon, Mar 05, 2012 at 03:53:28PM +0000, William Dunlap wrote:
> >> I haven't used Julia yet, but from my quick reading
> >> of the docs it looks like arguments to functions are
> >> passed by reference and not by value, so functions
> >> can change their arguments.  My recollection from when
> >> I first started using S (in the course of a job helping
> >> profs and grad students do statistical programming, c. 1983)
> >> is that not having to worry about in-place algorithms changing
> >> your data gave S a big advantage over Fortran or C.
> > [...]
> >
> >
> > C also uses Call-by-Value.
> 
> C *only* uses Call-by-Value.
> 
> Cheers,
> H.
> 
> > Fortran I don't know in detail.
> >
> >
> >> While this feature could slow things down and increase
> >> memory code, I felt that it made it easier to write correct
> >> code and to use functions that others had written.
> >
> > Yes, I also think, that call-by-value decreases
> > errors in Code.
> >
> > What I read about Julia it's like MATLAB plus more features for programming.
> > Does matlab also only use call-by-reference?
> >
> >
> >> Does Julia have a const declaration or other
> >> means of controlling or documenting that a given function
> >> will or will not change the data passed into it?
> >
> > I did not explored it in detail so far.
> > Maybe the orig-poster already did this in more depth?
> >
> >
> > Ciao,
> >     Oliver
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 
> --
> Herv? Pag?s
> 
> Program in Computational Biology
> Division of Public Health Sciences
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N, M1-B514
> P.O. Box 19024
> Seattle, WA 98109-1024
> 
> E-mail: hpages at fhcrc.org
> Phone:  (206) 667-5791
> Fax:    (206) 667-1319
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Julia
William Dunlap