PDA

View Full Version : accessing class methods & vars


mullins
10-06-2007, 09:57 AM
I have looked in several books and tried various implementations without finding out for sure, so...

Is there an equivalent of the "part named" function to allow access to (custom) methods and/or class variables for an object that is a parameter or an item in a list?

Examples of what I am looking for (any combination):

item_from_boxes.new_custom_method
item_from_boxes method called new_custom_method
if formal_param.my_var ...
if formal_params property called my_var ...

Thanks in advance for any help.

mullins
10-13-2007, 03:37 PM
I failed to mention that finding a way to use the class function
object's variable named ___ of type ___
would be useful.

I can't seem to find the context in which Alice will allow that function to be used.

DickBaldwin
10-13-2007, 05:20 PM
I failed to mention that finding a way to use the class function
object's variable named ___ of type ___
would be useful.

I can't seem to find the context in which Alice will allow that function to be used.

Take a look at the following to see if it contains the answer to your question.


See http://www.dickbaldwin.com/alice/Ali..._cast_operator (http://www.dickbaldwin.com/alice/Alice0920.htm#Limitations_related_to_the_lack_of_a _cast_operator)

Also see "A serious restriction" at http://www.dickbaldwin.com/alice/Alice0145.htm

Dick Baldwin
http://www.dickbaldwin.com/toc.htm
http://www.dickbaldwin.com/tocalice.htm

mullins
10-22-2007, 02:48 PM
Take a look at the following to see if it contains the answer to your question.


Actually, I had looked at your tutorials and several books previously. It's all still inconclusive, to me at least.

Any official word would still be appreciated.

DickBaldwin
10-24-2007, 12:48 PM
I believe that I may have found a solution to some of the problems encountered when you need to call custom methods on objects stored as type Object.

It isn't very elegant. In fact, it is pretty ugly, but it doesn't offend my OOP sensibilities, so I would be willing to teach it to my students.

I am currently testing the approach to confirm that it really does work. I will be back in a couple of days to explain the approach, or to say that I was wrong and it really isn't a solution.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm

DickBaldwin
10-25-2007, 06:33 PM
I have looked in several books and tried various implementations without finding out for sure, so...

Is there an equivalent of the "part named" function to allow access to (custom) methods and/or class variables for an object that is a parameter or an item in a list?

Examples of what I am looking for (any combination):

item_from_boxes.new_custom_method
item_from_boxes method called new_custom_method
if formal_param.my_var ...
if formal_params property called my_var ...

Thanks in advance for any help.

Take a look at http://www.alice.org/community/showthread.php?p=3993#post3993 to see if it is of any help.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm

mullins
11-06-2007, 08:00 AM
I think I prefer to describe the inability to access user defined properties and methods as a weakness. How big a weakness it is depends on what you are doing, of course.

I have written several programs to test the boundaries of the language. One uses a large number of boxes to simulate heat diffusion in a thin metal bar. Not being able to access the "finite element" methods is quite a pain. But, I wouldn't want to search through all the elements to call the method directly.
Rather, it seems a good motovation for moving to another language.

Thanks for all your efforts, though! Truly appreciated.