Is [variable] not object?

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

Is [variable] not object?

ChanHong Kim
Hi, all.

I'm writing the Dolphin Smalltalk tutorial in Korean.So I'll explain
[variables] in philosopical method.

In Smalltalk, "Everything is Object", however, variable is not.
I can't send any message variable itself. The message sent to the
object which is bind that variable.

How can I explain such situation? Please tell me good idea about
explain the concept of Smalltalk's variables.

Have a nice day.


Reply | Threaded
Open this post in threaded view
|

Re: Is [variable] not object?

Reinout Heeck
ChanHong Kim wrote:

>
> I'm writing the Dolphin Smalltalk tutorial in Korean.So I'll explain
> [variables] in philosopical method.
>
> In Smalltalk, "Everything is Object", however, variable is not.
> I can't send any message variable itself. The message sent to the
> object which is bind that variable.
>
> How can I explain such situation? Please tell me good idea about
> explain the concept of Smalltalk's variables.
>


Perhaps describe variables as collections of slots?
Instance vars are slots in an object,
Global vars are slots in a dictionary object,
temp vars are ad-hoc slots you can request by writing their names between
two vertical bars.

Since slots are part of an object they are not objects.


R
-


Reply | Threaded
Open this post in threaded view
|

Re: Is [variable] not object?

Marc Michael
In reply to this post by ChanHong Kim
ChanHong Kim wrote:

> Hi, all.
>
> I'm writing the Dolphin Smalltalk tutorial in Korean.So I'll explain
> [variables] in philosopical method.
>
> In Smalltalk, "Everything is Object", however, variable is not.
> I can't send any message variable itself. The message sent to the
> object which is bind that variable.
>
> How can I explain such situation? Please tell me good idea about
> explain the concept of Smalltalk's variables.
>
> Have a nice day.

Ok, the philosophical method.

Smalltalk consists of 2 layers:

1. The objects system.
Simply everything is an object. All is based on sending messages to
objects. There's nothing else.

2. The language.
The Smalltalk language is simply a macro language, or meta language. It
provides an easy to use way to work with objects and send messages to
them. Variables and the "assignment operator" := are simply syntax sugar.

All global variables are simply entries in the global dictionary named
Smalltalk. You can directly work with this dictionary to work with
global variables.

Something the same is with local variables, especially workspace
variables. The implementation of the "macro languages" differs here from
implementation to implementation. In Dolphin Smalltalk, workspace
variables are local to the workspace where they were created. In
Smalltalk/X on the other hand, all workspace variables are shared
between all workspaces.

Take a look at the documentation of Gnu Smalltalk. There's included a
nice tutorial, where you can directly discover this behaviar of "syntax
sugar" and how variables work.

Have a nice day,
Yogi