Dear Experts:

    I am very appreciate your comments and help!

    Actually I am a new comer from MATLAB. If the function

can see global variables, then it may output wrong results without

any error messages. For example, there is a gloabl variable named

v, and I write one funciton with one local variable x. However, in some
line,

I misspelled x to v, which would results in unexpected errors without
warning.

    In summary, I want to disable the ability to make debugging easier.

    Best.


2013/11/5 Carl Witthoft <c...@witthoft.com>

> Why would you want to impose this restriction?  Perhaps if you explain what
> you are trying to do, we can suggest approaches that will satisfy your
> specific needs.
> (note- one can always redefine whatever variables are to be "excluded."
> E.g.
> to keep the body of a function from referring to 'foo' in the calling
> environment, just add the line 'foo<-NA' inside the function)
>
>
> Zhong-Yuan Zhang wrote
> >      In MATLAB, functions cannot see variables outside the
> >
> > functions.  However, in R, the functions can do that. Is there
> >
> > any settings that can disable this ability of functions?
> >
> >
> > ______________________________________________
>
> > R-help@
>
> >  mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Function-does-not-see-variables-outside-the-function-tp4679762p4679768.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Zhong-Yuan Zhang (PhD.)
Associate Professor
School of Statistics
Central University of Finance and Economics
39 South College Road, Haidian District, Beijing, P.R.China 100081
Email: zhyua...@gmail.com
Homepage: http://en.stat.cufe.edu.cn/zhongyuanzhang/

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to