Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] rebol weak points (i think) Re:(2)

From: rishi:picostar at: 9-Sep-2000 19:12

no. The Math/Pie you have created is an instance variable not a static variable. It is associated with an instance of the class, not the class itself. A static variable means that there is a single copy of this variable associated with class itself. You do not need to instantiate a class to use static variable. For example: make-circle: make func [ radius /local blah-blah-blah /static num_circles ;let's say this is how you create static var. ] [ num_circles: num_circles + 1 ;this may not be correct but you get the idea... return make object! [ ;object code goes here ] ] small-circle: make-math(2) large-circle: make-math(100) print make-circle/num-circles ;this should hypothetically print out 2 print num-circles ;should print error Unfortunately, it would not make sense to add a static option the way I have done it since not all functions return objects. Anyway, the fact that rebol does not have static variables and static functions is no big deal. It was probably a concious decision not to include it. The main advantage of having static variables would be to prevent name collisions and to group variables/functions that act on a class (not an object) together for use in a more natural way. The main disadvantage of having static variables is that perhaps it is an unnecessary complication. But I don't think so. Maybe because I come from java/javascript background. I'm still wondering though if there is a way to have static variables that I don't know. Regardless, the main problem that I wonder about is if rebol is suited for modular programming where people reuse other people's functions/code. Since everything is either global or local, it seems as though it would be unnatural to use rebol in this way. Java has packages and stuff...perhaps I am not thinking straight and have too much java in my blood (which I have been doing to much of lately and finally got sick of all the abstractions that got in the way of doing simple stuff!!) Rishi