hi ho hi ho hi ho hi ...
please note all..
as usual with functions, with objects to..
(i know you know, why else clone-object.. :)

   a: make object! [static: make object! [pie: 20]] 
and a/static/pie is static..
should one know again :)

Volker

[rebol [] 
?do: func [todo] [prin ">> do " probe :todo prin "== " probe do todo] 
a: make object! [static: make object! [pie: 20]] 
b: make a [] 
c: make a [] 
? a ? b 
print "------" 
?do [b/static/pie: 10] 
? a ? b
]
>>>>>
A is an object of value: 
make object! [
static: 
make object! [
pie: 20
]
]
B is an object of value: 
make object! [
static: 
make object! [
pie: 20
]
]
------
>> do [b/static/pie: 10]
== 10
A is an object of value: 
make object! [
static: 
make object! [
pie: 10
]
]
B is an object of value: 
make object! [
static: 
make object! [
pie: 10
]
]


[EMAIL PROTECTED] wrote on 9-Sep-2000/19:12:06-7:00

> 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
> 
> 
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, September 09, 2000 6:03 PM
> Subject: [REBOL] rebol weak points (i think) Re:
> 
> 
> > Rishi wrote:
> > > Math.pi=20
> >
> > >> Math: make object! [
> > [    Pie: 20
> > [    ]
> > >> Math/Pie
> > == 20
> > >> Pie
> > ** Script Error: Pie has no value.
> > ** Where: Pie
> > >>
> >
> > Andrew Martin
> > ICQ: 26227169
> > http://members.xoom.com/AndrewMartin/
> > -><-
> >
> >
> 
> 
> 

Reply via email to