Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Reasons for which functions are not allowed within scripts?
Replies: 46   Last Post: Feb 1, 2011 2:21 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alan

Posts: 151
Registered: 7/24/09
Re: Reasons for which functions are not allowed within scripts?
Posted: Dec 17, 2010 5:08 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"EBS " <ericDOTsampson@gmail.com> wrote in message <ieebfa$9os$1@fred.mathworks.com>...
> "Steven_Lord" <slord@mathworks.com> wrote in message <ieb2la$hnp$1@fred.mathworks.com>...
> >
> >
> > "Andrea Tagliasacchi" <andrea.tagliasacchi@gmail.com> wrote in message
> > news:iearcf$818$1@fred.mathworks.com...

> > > You don't need to go that hardcore. Matlab could simply allow 1-level of
> > > functions (no nesting) in scripts only (no command line) and don't allow
> > > those functions to be scoped *outside* the script. It's not that hard and
> > > would allow for much more legible code!

> >
> > It may be possible to do that; I haven't thought through all the
> > difficulties.
> >
> > I have to question both parts of your assertion, though. It likely would be
> > hard to make sure there are no edge/special cases that will cause problems
> > other than the "something that's possible to do in scripts but not in the
> > command line", and "have a scope that's partway between script and function
> > file" special cases that you're already asking for. I also disagree that
> > the code would be any more legible than either converting your file into a
> > function file or pulling the subfunction into a separate file. [If you're
> > worried about namespacing, use a private function or a package directory.]
> >
> > I also question whether there's sufficient demand for this feature -- I
> > don't remember the last time someone asked for this functionality.
> >
> > But if you feel that strongly, submit this request (along with a clear
> > description of your use case) to Technical Support for capturing in the
> > enhancement database.
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> > comp.soft-sys.matlab (CSSM) FAQ: http://matlab.wikia.com/wiki/FAQ
> > To contact Technical Support use the Contact Us link on
> > http://www.mathworks.com

>
> Steve, I for one have always thought this functionality would be nice to have, in the simple form outlined by Andrea. I think scripts are very popular among users, and I've seen some very ugly ones because there is no way to define local utility subfunctions. It would also make it easier to send your script to another user if you don't have to send a number of associated function files along for the ride.
>
> I also seem to remember seeing a number of user requests for this functionality in the DB...
>
> Regards,
> EBS


I would use this functionality as well, I find myself in Andrea's situation regularly. I usually choose to change the script into a function, and add a keyboard statement at the bottom, but that has always felt like a hack to me. It never occurred to me to ask to be able to define functions within scripts, because I assumed there was some architectural issue making it all but impossible.


Date Subject Author
12/13/10
Read Reasons for which functions are not allowed within scripts?
Andrea Tagliasacchi
12/13/10
Read Reasons for which functions are not allowed within scripts?
Ryan Miller
12/13/10
Read Reasons for which functions are not allowed within scripts?
Andrea Tagliasacchi
1/4/11
Read Reasons for which functions are not allowed within scripts?
Malcolm McLean
1/5/11
Read Reasons for which functions are not allowed within scripts?
grubin698
1/5/11
Read Re: Reasons for which functions are not allowed within scripts?
Walter Roberson
1/5/11
Read Re: Reasons for which functions are not allowed within scripts?
grubin698
1/5/11
Read Re: Reasons for which functions are not allowed within scripts?
Oleg Komarov
1/5/11
Read Re: Reasons for which functions are not allowed within scripts?
Walter Roberson
1/5/11
Read Re: Reasons for which functions are not allowed within scripts?
grubin698
1/5/11
Read Re: Reasons for which functions are not allowed within scripts?
Steven Lord
1/5/11
Read Re: Reasons for which functions are not allowed within scripts?
dpb
1/5/11
Read Re: Reasons for which functions are not allowed within scripts?
Daniel
1/5/11
Read Re: Reasons for which functions are not allowed within scripts?
mike zander
12/13/10
Read Re: Reasons for which functions are not allowed within scripts?
Derek Goring
12/13/10
Read Reasons for which functions are not allowed within scripts?
Dragan Mitrevski
12/13/10
Read Reasons for which functions are not allowed within scripts?
Matt J
12/13/10
Read Reasons for which functions are not allowed within scripts?
Andrea Tagliasacchi
12/13/10
Read Reasons for which functions are not allowed within scripts?
Matt J
12/13/10
Read Reasons for which functions are not allowed within scripts?
mike zander
12/15/10
Read Reasons for which functions are not allowed within scripts?
Andrea Tagliasacchi
12/15/10
Read Re: Reasons for which functions are not allowed within scripts?
Steven Lord
12/16/10
Read Re: Reasons for which functions are not allowed within scripts?
Andrea Tagliasacchi
12/16/10
Read Re: Reasons for which functions are not allowed within scripts?
Walter Roberson
12/16/10
Read Re: Reasons for which functions are not allowed within scripts?
EBS
12/17/10
Read Re: Reasons for which functions are not allowed within scripts?
Andrea Tagliasacchi
12/17/10
Read Re: Reasons for which functions are not allowed within scripts?
Steven Lord
12/17/10
Read Re: Reasons for which functions are not allowed within scripts?
EBS
12/17/10
Read Re: Reasons for which functions are not allowed within scripts?
Bjorn Gustavsson
12/17/10
Read Re: Reasons for which functions are not allowed within scripts?
Steven Lord
12/17/10
Read Re: Reasons for which functions are not allowed within scripts?
Alan
2/1/11
Read Re: Reasons for which functions are not allowed within scripts?
aslak grinsted
1/3/11
Read Reasons for which functions are not allowed within scripts?
Bob S
1/4/11
Read Re: Reasons for which functions are not allowed within scripts?
Greg Heath
1/4/11
Read Re: Reasons for which functions are not allowed within scripts?
Husam Aldahiyat
1/4/11
Read Re: Reasons for which functions are not allowed within scripts?
Greg Heath
1/27/11
Read Re: Reasons for which functions are not allowed within scripts?
per isakson
1/5/11
Read Reasons for which functions are not allowed within scripts?
Tod Gentille
1/20/11
Read Reasons for which functions are not allowed within scripts?
Sean
1/20/11
Read Re: Reasons for which functions are not allowed within scripts?
Steven Lord
1/26/11
Read Reasons for which functions are not allowed within scripts?
oyvist
1/26/11
Read Reasons for which functions are not allowed within scripts?
Andrea Tagliasacchi
1/26/11
Read Reasons for which functions are not allowed within scripts?
Charles
1/26/11
Read Reasons for which functions are not allowed within scripts?
Andrea Tagliasacchi
1/27/11
Read Reasons for which functions are not allowed within scripts?
oyvist
1/27/11
Read Reasons for which functions are not allowed within scripts?
Andrea Tagliasacchi
1/27/11
Read Re: Reasons for which functions are not allowed within scripts?
Walter Roberson

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.