Computer Science Canada Thoughts on Action Procedures and a Dynamic Number of Parameters. |
| Author: | Clayton [ Mon Nov 26, 2007 6:55 pm ] |
| Post subject: | Thoughts on Action Procedures and a Dynamic Number of Parameters. |
So I've recently been compelled to think about the age old problem of having an action procedure with a variable number of parameters for use with a GUI Widget (think buttons here). I've come up with a couple ideas on a rough design plan on how to implement it, and I keep getting close. However, everytime I think about that plan, it gets shot down because I have no clue as to how I would get to that magical dynamic number of parameters. Basically my plan thus far is to have a basic Action class. From that, when you code your program that uses buttons, you create a specific subclass of Action from which you can code in your action procedure. However, like I said above, the issue still comes up where you need to account for a variable number of parameters. That being said, I'm wondering if anyone out there might have an idea on how to do this. I'm really starting to miss Ruby's way of grouping multiple arguments into an array right now. |
|
| Author: | chrisciscoioio [ Mon Nov 26, 2007 7:43 pm ] |
| Post subject: | Re: Thoughts on Action Procedures and a Dynamic Number of Parameters. |
Hey, I gave up my Turing days years ago, but I know Inheritance would fit the bill, OO Turing has Inheritance. Read up on that some. For Unlimited Params, that is not done, just overload which all your workable options. I know this is how Java, C# solve problems to name a few. 10 cents Chris |
|
| Author: | md [ Mon Nov 26, 2007 8:00 pm ] |
| Post subject: | RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. |
maybe find a hackish way to look at the stack with pointers? I know C does variable number of parameters no problem, and since turing goes to C (or C++... whatever) it might support it too... More likely your SOL and you'll have to resort to some hackish array type call. |
|
| Author: | Clayton [ Mon Nov 26, 2007 8:04 pm ] |
| Post subject: | RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. |
Yes, and that's what I was afraid of. In the end, it will probably end up being some hackish type of solution. We shall see. |
|
| Author: | Nick [ Mon Nov 26, 2007 11:34 pm ] | ||
| Post subject: | RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. | ||
think about how View.Set() works, it takes a single parameter as a string then checks that string for known code such as (pseudo code since im not sure how turing works this exactly)
thats what im ulimatly thinking about :\ EDIT: this should help http://compsci.ca/v3/viewtopic.php?t=4055 |
|||
| Author: | chrisciscoioio [ Tue Nov 27, 2007 12:36 am ] |
| Post subject: | Re: Thoughts on Action Procedures and a Dynamic Number of Parameters. |
I still think, the best and not hackish way is to do it through classes, with inheritance. Create overloaded methods (or whatever you want to call them). Yes turing has that View set, but is a very hackish method, very high chance of causing errors, because you would rely on the user knowing everything down to a nail. With OO classes you can quickly create the features, and include overloading for as many types as you need, as well as allowing other users to create other classes that use inheritance, and they can extend your class as needed. Lets see about some psuedo code class TButton { TButton (int x, int y, string name) { } TButton (int x, int y, string name, int colour) { } } My second 10 cents Chris |
|
| Author: | zylum [ Tue Nov 27, 2007 12:43 am ] |
| Post subject: | RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. |
im pretty sure turing doesnt support method overloading |
|
| Author: | chrisciscoioio [ Tue Nov 27, 2007 12:53 am ] |
| Post subject: | Re: Thoughts on Action Procedures and a Dynamic Number of Parameters. |
It does, and second arg to you, stupid cannot edit a post that has been replied to, I just finished it. This snippet is from holtsoft, I duno like I said I gave up Turing years ago, but the programming concepts are still the same. Quote: Object Oriented Programming in Turing - Advanced
The course uses the Object Oriented Turing programming language to provide a brief overview of object-oriented concepts before proceeding to advanced concepts. These include: abstract classes, polymorphism, factoring (object-oriented design), genericity, method overloading, operator overloading, and multiple inheritance. There will also be a walkthrough of a large project which incorporates many of these principles. (Lab required, Turing software will be provided) Also since I cannot edit that top post anymore, basicly you need to look to OO Turing and then you should be able to do it, it will not be easy, but go for it. Reason it is 1 AM, and that was approx 15 or so minutes of typing, and I am tired, maybe I will add it again later. |
|
| Author: | zylum [ Tue Nov 27, 2007 12:59 am ] | ||
| Post subject: | RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. | ||
correct me if im wrong but this:
is method overloading... doesn't seem to work, does it? |
|||
| Author: | Clayton [ Tue Nov 27, 2007 12:03 pm ] |
| Post subject: | RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. |
No. Turing does not support method overloading. However, I am thinking of something slightly hackish, although not entirely hackish. I'll explain later when I have more time. |
|
| Author: | chrisciscoioio [ Tue Nov 27, 2007 12:26 pm ] |
| Post subject: | Re: RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. |
Clayton @ Tue Nov 27, 2007 12:03 pm wrote: No. Turing does not support method overloading. However, I am thinking of something slightly hackish, although not entirely hackish. I'll explain later when I have more time.
Ask Holtsoft, not that they will answer, but there site is still there and it says that it does, and really if it has classes it needs overloading. You can look at my quote or here: http://www.holtsoft.com/courses/description.html Look for Object Oriented Programming in Turing - Advanced Header I mean as far as I can see it does, like I said I gace up turing for C++ and Game Programming, but it is wite there it sayd it does. |
|
| Author: | Clayton [ Tue Nov 27, 2007 5:46 pm ] |
| Post subject: | RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. |
And I'm telling you, Turing does not support method overloading. And if it does, it's most likely going to involve something that's not exactly worth the effort. On top of that, Turing doesn't support multiple inheritance, nor does it support operator overloading. If you read closer, you'll see that the section quoted is from a course description page. Not a language reference. |
|
| Author: | chrisciscoioio [ Tue Nov 27, 2007 10:43 pm ] | ||
| Post subject: | Re: Thoughts on Action Procedures and a Dynamic Number of Parameters. | ||
I guess that is what I get for playing with good programming lanuages, I assumed that when they used classes they would support an actual class, not just make module, group, package, they are deceptive. I also kind thought that when the course description says there will be a lab with the involved topics and Turing will be provided it means it can be done. Anyways, Hackish method.
For reference, the i stand for int, it a pseudo code way of showing what params are accepted, so... i = int s = string r = real b = boolean and so forth. |
|||
| Author: | Clayton [ Wed Nov 28, 2007 4:41 pm ] |
| Post subject: | RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. |
That.... is beyond hackish to me. I think what I'm going to end up doing is creating a basic Object class. From that, I will subclass Integers, Strings, Floats, Booleans. Then, in my GUI class, I will have the action procedure take in an array of Objects. Hackish I know, but... not bad when considering the alternative. |
|
| Author: | chrisciscoioio [ Wed Nov 28, 2007 11:13 pm ] |
| Post subject: | Re: Thoughts on Action Procedures and a Dynamic Number of Parameters. |
Thats not a bad idea, it might work, less hackish. My hackish method stepping over the compile phase, since that is what they tag overloaded methods like, except it is at the beginning no underscore and its in assembly. But you know. |
|
| Author: | Dan [ Wed Nov 28, 2007 11:33 pm ] |
| Post subject: | RE:Thoughts on Action Procedures and a Dynamic Number of Parameters. |
Althought chrisciscoioio method may seem out there it is aucatly close to what some c librays like OpenGL does to over come the lack of method overloading. When you think about it there is litte diffrence from overloading a method to just making a diffrently named method that does about the same thing. Since you have to know how many vars you are passing you could also know what method name to use. Not as prity but it is the closest thing to function overloading in langues that do not have them. |
|
| Author: | richcash [ Sat Dec 01, 2007 6:54 pm ] | ||||
| Post subject: | Re: Thoughts on Action Procedures and a Dynamic Number of Parameters. | ||||
I don't know if anyone has heard of sets. Unfortunately there's not much at all you can do with a set. You can only check if something is a member of a set using in. So you're procedure ends up looking ugly.
That's just to output the values in the set. I guess to manage the parameters normally you would put them in an array. The REALLY bad thing is there's no repeated values in a set (since it's supposed to represent a mathematical set). There also seems to be some issues with sets (such as not detecting 0, weird things happening when your range is minint .. maxint, etc.).I don't think this is the answer to dynamic number of parameters unless your procedure only uses integer or char parameters. |
|||||