| MATLAB Central > MATLAB Newsreader > Reasons for which functions are not allowed within... |
|
|
|
Subject: Reasons for which functions are not allowed within scripts? From: Andrea Tagliasacchi Date: 13 Dec, 2010 19:31:04 Message: 1 of 47 |
|
Hello everybody, |
|
Subject: Reasons for which functions are not allowed within scripts? From: Ryan Miller Date: 13 Dec, 2010 20:20:09 Message: 2 of 47 |
|
If you want to hang on to the variables, why not just declare them as global? Keeping everything in functions seems nice for housekeeping purposes. |
|
Subject: Reasons for which functions are not allowed within scripts? From: Andrea Tagliasacchi Date: 13 Dec, 2010 21:09:07 Message: 3 of 47 |
|
> If you want to hang on to the variables, why not just declare them as global? Keeping everything in functions seems nice for housekeeping purposes. |
|
Subject: Reasons for which functions are not allowed within scripts? From: TideMan Date: 13 Dec, 2010 21:16:33 Message: 4 of 47 |
|
On Dec 14, 8:31 am, "Andrea Tagliasacchi" |
|
Subject: Reasons for which functions are not allowed within scripts? From: Dragan Date: 13 Dec, 2010 21:25:29 Message: 5 of 47 |
|
Why not just return the variables from the function, even though the function only is plotting something? |
|
Subject: Reasons for which functions are not allowed within scripts? From: Matt J Date: 13 Dec, 2010 21:57:04 Message: 6 of 47 |
|
"Andrea Tagliasacchi" <andrea.tagliasacchi@gmail.com> wrote in message <ie5s9o$jef$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Andrea Tagliasacchi Date: 13 Dec, 2010 22:18:05 Message: 7 of 47 |
|
Why not stick in a keyboard command at the bottom of the main() function?Then you can work from the >> prompt inside the workspace of main() just as you would work from the normal prompt. |
|
Subject: Reasons for which functions are not allowed within scripts? From: Matt J Date: 13 Dec, 2010 22:44:05 Message: 8 of 47 |
|
"Andrea Tagliasacchi" <andrea.tagliasacchi@gmail.com> wrote in message <ie662t$qjt$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Matt Fig Date: 13 Dec, 2010 23:08:21 Message: 9 of 47 |
|
"Andrea Tagliasacchi" <andrea.tagliasacchi@gmail.com> wrote in message <ie5s9o$jef$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Andrea Tagliasacchi Date: 15 Dec, 2010 16:46:07 Message: 10 of 47 |
|
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! |
|
Subject: Reasons for which functions are not allowed within scripts? From: Steven_Lord Date: 15 Dec, 2010 18:50:17 Message: 11 of 47 |
|
|
|
Subject: Reasons for which functions are not allowed within scripts? From: Andrea Tagliasacchi Date: 16 Dec, 2010 18:15:24 Message: 12 of 47 |
|
MATLAB intro course (whereever you did it), lesson 2: "functions cannot be defined in scripts". That's why people don't bother... getting used to something is a powerful inhibitor. |
|
Subject: Reasons for which functions are not allowed within scripts? From: Walter Roberson Date: 16 Dec, 2010 18:59:40 Message: 13 of 47 |
|
On 10-12-16 12:15 PM, Andrea Tagliasacchi wrote: |
|
Subject: Reasons for which functions are not allowed within scripts? From: EBS Date: 17 Dec, 2010 00:39:06 Message: 14 of 47 |
|
"Steven_Lord" <slord@mathworks.com> wrote in message <ieb2la$hnp$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Andrea Tagliasacchi Date: 17 Dec, 2010 09:27:05 Message: 15 of 47 |
|
> 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. |
|
Subject: Reasons for which functions are not allowed within scripts? From: Steven_Lord Date: 17 Dec, 2010 14:40:56 Message: 16 of 47 |
|
|
|
Subject: Reasons for which functions are not allowed within scripts? From: EBS Date: 17 Dec, 2010 19:29:05 Message: 17 of 47 |
|
"Steven_Lord" <slord@mathworks.com> wrote in message <iefspo$16k$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Bjorn Gustavsson Date: 17 Dec, 2010 20:11:21 Message: 18 of 47 |
|
"EBS " <ericDOTsampson@gmail.com> wrote in message <iegdm1$nmm$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Steven_Lord Date: 17 Dec, 2010 21:59:49 Message: 19 of 47 |
|
|
|
Subject: Reasons for which functions are not allowed within scripts? From: Alan B Date: 17 Dec, 2010 22:08:04 Message: 20 of 47 |
|
"EBS " <ericDOTsampson@gmail.com> wrote in message <ieebfa$9os$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Bob S Date: 3 Jan, 2011 23:57:07 Message: 21 of 47 |
|
I couldn't agree more. It bugs me a lot too. (I would also add inability to define functions on the command line, although that's much less important.) |
|
Subject: Reasons for which functions are not allowed within scripts? From: Greg Heath Date: 4 Jan, 2011 05:46:30 Message: 22 of 47 |
|
On Jan 3, 6:57 pm, "Bob S" <rvsass...@hotmail.dropthis.com> wrote: |
|
Subject: Reasons for which functions are not allowed within scripts? From: Husam Aldahiyat Date: 4 Jan, 2011 07:41:04 Message: 23 of 47 |
|
Greg Heath <heath@alumni.brown.edu> wrote in message <20a9b2c5-5fed-4a49-a680-26d6faf28c16@n10g2000yqd.googlegroups.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Greg Heath Date: 4 Jan, 2011 08:31:43 Message: 24 of 47 |
|
On Dec 13 2010, 2:31 pm, "Andrea Tagliasacchi" |
|
Subject: Reasons for which functions are not allowed within scripts? From: Malcolm McLean Date: 4 Jan, 2011 08:33:04 Message: 25 of 47 |
|
"Ryan Miller" wrote in message <ie5v5p$ejn$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Gary Date: 5 Jan, 2011 14:52:05 Message: 26 of 47 |
|
I also would like to see that feature. I find that I often put breakpoints at the end of my functions so that I can have access to the data for investigation, visualization, etc. |
|
Subject: Reasons for which functions are not allowed within scripts? From: Walter Roberson Date: 5 Jan, 2011 15:02:24 Message: 27 of 47 |
|
On 05/01/11 8:52 AM, Gary wrote: |
|
Subject: Reasons for which functions are not allowed within scripts? From: Gary Date: 5 Jan, 2011 15:22:05 Message: 28 of 47 |
|
> I don't understand, Gary, how allowing functions to be defined within |
|
Subject: Reasons for which functions are not allowed within scripts? From: Matt Fig Date: 5 Jan, 2011 15:23:04 Message: 29 of 47 |
|
Walter Roberson <roberson@hushmail.com> wrote in message <5K%Uo.1840$rG3.1555@newsfe09.iad>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Oleg Komarov Date: 5 Jan, 2011 15:31:05 Message: 30 of 47 |
|
"Gary" wrote in message <ig22at$bd8$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Walter Roberson Date: 5 Jan, 2011 15:37:31 Message: 31 of 47 |
|
On 05/01/11 9:22 AM, Gary wrote: |
|
Subject: Reasons for which functions are not allowed within scripts? From: Gary Date: 5 Jan, 2011 16:00:26 Message: 32 of 47 |
|
|
|
Subject: Reasons for which functions are not allowed within scripts? From: Steven_Lord Date: 5 Jan, 2011 18:00:32 Message: 33 of 47 |
|
|
|
Subject: Reasons for which functions are not allowed within scripts? From: dpb Date: 5 Jan, 2011 18:55:12 Message: 34 of 47 |
|
Gary wrote: |
|
Subject: Reasons for which functions are not allowed within scripts? From: Daniel Date: 5 Jan, 2011 19:37:04 Message: 35 of 47 |
|
While I am one of the people against functions in scripts, if that is really what you want ... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Tod Date: 5 Jan, 2011 20:29:05 Message: 36 of 47 |
|
"Andrea Tagliasacchi" <andrea.tagliasacchi@gmail.com> wrote in message <ie5s9o$jef$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Sean de Date: 20 Jan, 2011 15:32:04 Message: 37 of 47 |
|
"Andrea Tagliasacchi" <andrea.tagliasacchi@gmail.com> wrote in message <ie5s9o$jef$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Steven_Lord Date: 20 Jan, 2011 15:55:58 Message: 38 of 47 |
|
|
|
Subject: Reasons for which functions are not allowed within scripts? From: Øyvind Date: 26 Jan, 2011 15:26:03 Message: 39 of 47 |
|
This is a piece of functionality that I really miss in Matlab, and which is available in other languages, such as Python, Ruby and Lua. I've always been wowed at the ability to create functions and classes and so on from Python's command line (and nested classes, which are as yet not possible in Matlab). |
|
Subject: Reasons for which functions are not allowed within scripts? From: Andrea Tagliasacchi Date: 26 Jan, 2011 16:39:04 Message: 40 of 47 |
|
Hello Everybody, |
|
Subject: Reasons for which functions are not allowed within scripts? From: Charles Date: 27 Jan, 2011 01:51:05 Message: 41 of 47 |
|
I've been working with Matlab for 14 years, and this restriction has been there the entire time. Yes, it is a pain sometimes, but I think it forces me to write better code. |
|
Subject: Reasons for which functions are not allowed within scripts? From: Andrea Tagliasacchi Date: 27 Jan, 2011 02:34:04 Message: 42 of 47 |
|
> Well anyway, I'm sure someone has found workarounds to my own complaints about Matlab. But to me, I find the script limitation a bother sometimes, but an acceptable bother. I'd rather live with it than have some new perverse model of software structure that allowed functions in scripts. |
|
Subject: Reasons for which functions are not allowed within scripts? From: Øyvind Date: 27 Jan, 2011 15:04:03 Message: 43 of 47 |
|
"Andrea Tagliasacchi" <andrea.tagliasacchi@gmail.com> wrote in message <ihqlir$hll$1@fred.mathworks.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: Andrea Tagliasacchi Date: 27 Jan, 2011 17:23:03 Message: 44 of 47 |
|
> I agree. And most of the objections against your suggestion are as far as I can tell objections against scripts in general, not objections against functions inside scripts per se. |
|
Subject: Reasons for which functions are not allowed within scripts? From: Think blue, count two. Date: 27 Jan, 2011 17:54:44 Message: 45 of 47 |
|
On 26/01/11 8:34 PM, Andrea Tagliasacchi wrote: |
|
Subject: Reasons for which functions are not allowed within scripts? From: per isakson Date: 27 Jan, 2011 22:39:04 Message: 46 of 47 |
|
Greg Heath <heath@alumni.brown.edu> wrote in message <d182b6e2-f0ce-4cbb-a7bd-a1d631aa6283@r29g2000yqj.googlegroups.com>... |
|
Subject: Reasons for which functions are not allowed within scripts? From: aslak grinsted Date: 1 Feb, 2011 07:21:03 Message: 47 of 47 |
|
|
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
| Tag Activity for This Thread | ||
|---|---|---|
| Tag | Applied By | Date/Time |
| subclasses | Aslak Grinsted | 1 Feb, 2011 02:24:34 |
| feature request | Aslak Grinsted | 1 Feb, 2011 02:24:34 |
| functions | Aslak Grinsted | 1 Feb, 2011 02:24:34 |
| script | Aslak Grinsted | 1 Feb, 2011 02:24:34 |
| script functions | Charles | 26 Jan, 2011 20:54:29 |
| dead_horse | Matt Fig | 26 Jan, 2011 11:51:41 |
| workspace | EBS | 17 Dec, 2010 14:34:18 |
| script | EBS | 17 Dec, 2010 14:34:17 |
| general programmin... | Andrea Tagliasacchi | 13 Dec, 2010 14:34:07 |
| scripts | Andrea Tagliasacchi | 13 Dec, 2010 14:34:07 |
| functions | Andrea Tagliasacchi | 13 Dec, 2010 14:34:07 |
