Propeller Tool Limits
RogerInHawaii
Posts: 87
The Propeller Tool has a couple of limits that I've recently encountered:
·· 1. Variable names (as well as method names, constant names, etc) are limited to a maximum of 30 characters each
·· 2. The number of parameters that a method may have is limited to 15
These seem like the kinds of limitations that one would have imposed back in the early days of programming languages when every byte of memory or disk space was at a·premium. That has not been the case for decades.
I have situations where it would be very helpful to NOT have such limits. Are there valid reasons for these limitations? Is there any way to overcome these limitations?
·· 1. Variable names (as well as method names, constant names, etc) are limited to a maximum of 30 characters each
·· 2. The number of parameters that a method may have is limited to 15
These seem like the kinds of limitations that one would have imposed back in the early days of programming languages when every byte of memory or disk space was at a·premium. That has not been the case for decades.
I have situations where it would be very helpful to NOT have such limits. Are there valid reasons for these limitations? Is there any way to overcome these limitations?
Comments
The first question that comes to my mind is why on earth would you ever want even 30-character variable names or 15 method parameters? Variable names even half that long will disrupt a program's readability by stretching math expressions to enormous lengths. And too many parameters in a method call also make a program difficult to follow. (Let's see: is positionX parameter 9 or parameter 10? Okay: 1, 2, 3, 4, 5, ... oh, right, it's 8.) In the latter case, a pointer to an array is probably the better choice. That way you can fill the parameter list using named constants as indices, viz:
-Phil
As for using arrays with "named" subscripts as a means of passing values to a method, that's more of a way around the limitation than a means of making the program more readable.·I'll acknowledge that in this very simple, non-typed programming language it does make it difficult to make sure that the parameters "line up".
-Phil
As for positional parameter association, I worked on the Ada programming language many, many·years ago, and as I recall·it allowed you to specify the names of the parameters when you called·a method, so ordering didn't much matter.
For example, if you had a method defined like this:
··· MyMethod(int Fred, int Mary, int Joe)
you could call it like this:
·· MyMethod(Joe = 13, Mary = 7, 6)
The 6 would end up in Fred, since it was the only one left.
·
But the limit of 15 parameters in my opinion is not to bad and if you need more you do something wrong! You should keep in mind that the propeller is a microcontroller with very limited resources. Why would there be a need to put variables from variable-space to stack-space? You have doubled the need of resources (memory) and you increase runtime. Besides that it might be a interpreter limitation. Maybe in the bytecode there is only room for 4bit stack-relative adresses, which is 15 parameters plus return value = 16.
I can't say whether the length of variable names is a named constant in the compiler code. Keep in mind that the Parallax Spin compiler is written in assembly language for Windows, so it's probably not as flexible as you might think. The two 3rd party Spin compilers (BradC's and mpark's) should be much more flexible.
where the values after the colon are the defaults when the named argument is omitted from the call. Such a method could be called in the standard way:
or using named arguments:
In the latter case, the compiler would simply generate the same positional code as in the former case, filling in the default values for arguments that are absent. Mixing positional and named arguments would lead to ambiguities, though, and should not be allowed.
-Phil
I was going to carry on about the differences in paradigm between general purpose microprocessors and embedded microcontrollers, and the various uses, requirements, and limitations then I remembered, every day I deal with some of the same stone age limitations you are complaining about. My platform (the one I get paid for)? The IBM iSeries mid-range computer.
Chain saw
Hack saw
Which is a better saw?
Ned
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"They may have computers, and other weapons of mass destruction." - Janet Reno
It's hard to see which saw you need, until you see it as the saw sees the need.
Duffer
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"They may have computers, and other weapons of mass destruction." - Janet Reno
You mean it has a motor??? Gee no wonder it took me so long to cut that tree down!!
To be more specific, the limit in variable name length is a practical limit that helps keep the symbol table size from getting out of hand in the compiler.· We don't think there's enough reason for variable names greater than that size which outweighs the negative memory footprint effects it has on the compiler's run-time usage for every program that does not have such long variable names.· We feel that around 30 characters is a good practical limit.· I remember being limited to 2 character variable names when I first started programming... anything over 8 is wonderful to me... anything approaching 30 characters is way to long.· I know this topic is fodder for much debate as "memory" on the PC is virtually endless these days, but the overall goal of ours is to put the development tools in the Propeller chip itself (something we wanted to do with Propeller 1 but there just wasn't enough resources in that version to make it practical).· The Propeller 2 will likely have some development tools built-in (but of course we'll enhance the Propeller Tool to support it as well).
The limit of 15 parameters a chip-based and interpreter based.· Each parameter is stored on the stack, along with the return variable and other local variables.· Again, it was a "practical" design decision meant to be sufficiently high for most, if not all, applications, and not just one for run-time use, but also a practical limit to help guide people into coding efficiently on a microcontroller.·
While the variable limit size could change (in the compiler), and the parameter list size could change in the next Propeller chip, they are both unlikely to be changed unless we find an overwhelmingly compelling need for it.
Take care,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Jeff Martin
· Sr. Software Engineer
· Parallax, Inc.