Can you declare the data type of a parameter of a spin method?
joeysr20det
Posts: 8
Can you declare the data type of a parameter of a spin method? Where something like...
PUB myMethod(variable)
could say that variable is a float...
PUB myMethod(float(variable))
I'm not sure if you can do this with parameters. I need to be able to pass a float as a parameter to a method.
Thanks in advance.
PUB myMethod(variable)
could say that variable is a float...
PUB myMethod(float(variable))
I'm not sure if you can do this with parameters. I need to be able to pass a float as a parameter to a method.
Thanks in advance.
Comments
-Phil
You are just going to have to pass that float the same way as a long.
The programmer has to keep track of the data types in his program manually.
But then you'd loose any time you gained by having to type a zillion brackets.
There hasn't been a full fledge Spin vs C war yet has there? I keep waiting for it.
Too funny.
I won't start one because the conflict might cause bad feelings on one side or the other. The Official JavaScript Religious War thread was far enough removed from the core identity of this community that there was no danger of ill will. Plus I was sure that both Heater and I would see it as all in good fun.
However, I would start one if there were rules to make it funny. For example, suppose Team C must argue in favor of Spin, while Team Spin must argue in favor of C. Any time real aggression breaks out you get red carded, put in the "Forth Penalty Box", and now have to argue in favor of Forth. If the Forthers get nasty they get put into the "C Penalty Box", where they have to do their next project in C. That should keep everything mellow and possibly humorous.
The ultimate purpose is that there are things to like in all of these languages, and at the end of the day they all get the job done. What's funny is for a type safety zealot my last two projects have been in Forth, so I'm a huge hypocrite.
Another possibility would be to use implicit typing based on the first character of the variable name like Fortran does for integer variables starting with the letters I though N. A naming convention like I_VarA for integers, F_VarB for floats and S_VarC for strings might be a workable solution.
-Phil
The addition of type checking would just require checking the parameter types in the method call with the parameter types defined in the external object, or even within the same object. Make it optional and it has zero impact on programmers that don't want to use type checking. However, I think the use of type checking would be a great benefit to newbies.
Maybe someone can make a clone of OpenSpin that includes type checking plus some of the other features that people have been proposing. We can try out the clone, and some features may catch on and get incorporated into the official version of OpenSpin.
Novel idea. Maybe it should be a forum rule.
Fortunately there are only a few valuable aspects to other languages [:-1], and people can select from a language standard cliche list when called to the box.
-Phil
You can omit headers in C if you don't care for what they contain or reference. Really a bad idea though because it helps catch errors in programs.
-Phil
A plus of Spin is that it allows using byte,word,long etc... for casting data to a given element type.
Nah, not from me.
I have always been a "C/C++ on the Prop" evangelist and I'm fairly sure Spin is totally pointless anywhere else but on the Prop.
BUT the Propeller, Spin and PASM were designed together as an integrated whole. It's that "synergy" thing. The resulting system is small, elegant, powerful and very easy to use.
More concretely I mean:
1) Spin and it's byte codes enable a lot of functionality to be squeezed into the small memory space of the Prop which is hard to do otherwise.
2) When you need speed PASM comes to hand very easily, being integrated into Spin. The Prop instruction set and PASM in Spin makes for one of the simplest assembly language programming systems ever. Almost as easy to use as an HLL.
3) Spin is very easy for beginners to get started with or for the more experienced to knock up a quick project. This is all to do with it's simple syntax, lack types, no header files, the object system and so on.
Spin does not hold a candle to pretty much all other general purpose high level languages from ALGOL and FORTRAN to Java and JavaScript. I can't see anyone ever wanting to implement Spin for platforms other than the Propeller. What would be the point when there are so many better alternatives?
The Propeller/Spin/PASM combination though is a wonderful thing.
I'm with Martin, language wars should be pursued with good humour for a bit of fun. Some would say language wars are pointless bickering and endless regurgitation of old arguments. On the other hand a good language good war debate can be informative and educational for those that don't know much about one or other of the languages involved.
Of course one can get a bit heated when your opponent is to stupid to realize why your preferred language is obviously far superior to theirs
I'm dead against having prefixes on variable names specify their type FORTRAN style. e.g. I_myInteger. With that simple change you make nice clean looking Spin code into an ugly mess of underscores and camel case. yuk.