can we have Class instance variables ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

can we have Class instance variables ?

leonsmith
I distinctly remember reading that Amber doesn't allow Class instance
variables, and I see how Smalltalk handles that by using the
Javascript version <smalltalk>, but today I noticed that Transcript
actually has a class-side instance variable. Is that because that
Class will never get exported to Javascript, or can we actually use
them with the same syntax as Transcript ?
Reply | Threaded
Open this post in threaded view
|

Re: can we have Class instance variables ?

gokr
Again read the page on porting on the wiki - Amber supports class instance vars but not class vars. Regarding pragmas, I refer to Nicolas. Perhaps it is just a "someone has to do it"-thing.

regards, Göran



-- Sent from my Palm Pre 2, wohoo!


On Feb 19, 2012 18:54, leonsmith <[hidden email]> wrote:

I distinctly remember reading that Amber doesn't allow Class instance
variables, and I see how Smalltalk handles that by using the
Javascript version <smalltalk>, but today I noticed that Transcript
actually has a class-side instance variable. Is that because that
Class will never get exported to Javascript, or can we actually use
them with the same syntax as Transcript ?
Reply | Threaded
Open this post in threaded view
|

Re: can we have Class instance variables ?

leonsmith
Thanks for the clarification Goran. This helps a lot. Its not just a
"nice to have" but absolutley necessary for some things like
Singletons as you know. I'll be more careful in my reading, thanks.

On Feb 19, 12:36 pm, "Göran Krampe" <[hidden email]> wrote:
> Again read the page on porting on the wiki - Amber supports class instance vars but not class vars. Regarding pragmas, I refer to Nicolas. Perhaps it is just a "someone has to do it"-thing.
> regards, Göran-- Sent from my Palm Pre 2, wohoo!On Feb 19, 2012 18:54, leonsmith <[hidden email]> wrote:I distinctly remember reading that Amber doesn't allow Class instance
> variables, and I see how Smalltalk handles that by using the
> Javascript version <smalltalk>, but today I noticed that Transcript
> actually has a class-side instance variable. Is that because that
> Class will never get exported to Javascript, or can we actually use
> them with the same syntax as Transcript ?
Reply | Threaded
Open this post in threaded view
|

Re: can we have Class instance variables ?

gokr
On 02/20/2012 05:24 PM, leonsmith wrote:
> Thanks for the clarification Goran. This helps a lot. Its not just a
> "nice to have" but absolutley necessary for some things like
> Singletons as you know. I'll be more careful in my reading, thanks.

I don't consider class vars to be "absolutely necessary" for Singletons
- not sure if that was what you meant. To make a singleton - just use a
class *instance* variable and then create a class side accessor (like
for example #instance) for it so that you can write:

        MySingletonClass instance

regards, Göran
Reply | Threaded
Open this post in threaded view
|

Re: can we have Class instance variables ?

Nicolas Petton
Most of the time, class variables should actually be class instance
variables. Singleton is a good example of that.

I never missed class variables in Amber, since class ivars are a better
choice 99% of the time anyway, like Amber doesn't support pool dictionaries.

Cheers,
Nico


On 20/02/12 20:54, Göran Krampe wrote:

> On 02/20/2012 05:24 PM, leonsmith wrote:
>> Thanks for the clarification Goran. This helps a lot. Its not just a
>> "nice to have" but absolutley necessary for some things like
>> Singletons as you know. I'll be more careful in my reading, thanks.
>
> I don't consider class vars to be "absolutely necessary" for Singletons
> - not sure if that was what you meant. To make a singleton - just use a
> class *instance* variable and then create a class side accessor (like
> for example #instance) for it so that you can write:
>
> MySingletonClass instance
>
> regards, Göran


--
Nicolas Petton
http://nicolas-petton.fr
Reply | Threaded
Open this post in threaded view
|

Re: can we have Class instance variables ?

gokr
On 02/21/2012 10:48 AM, Nicolas Petton wrote:
> Most of the time, class variables should actually be class instance
> variables. Singleton is a good example of that.
>
> I never missed class variables in Amber, since class ivars are a better
> choice 99% of the time anyway, like Amber doesn't support pool
> dictionaries.

Agree 100%. Class vars are basically scoped globals. IMHO we can do fine
with the only globals we have in Amber: classes.

regards, Göran