List Info

Thread: Re: Smalltalk scripting syntax




Re: Smalltalk scripting syntax
country flaguser name
Italy
2007-03-13 01:08:14
>     Object subclass: #MyClass.
>     MyClass comment: 'A simple example class'.

Except that MyClass is not available yet...

One would need something like

        Object subclass: #MyClass!
        MyClass comment: 'A simple example class'!

or

    Eval [
        Object subclass: #MyClass.
    ]
    Eval [
        MyClass comment: 'A simple example class'.
    ]

>   * Class and instance variables are defined the same
way, except that
> class variables are defined within class method
definition scope and
> instance variables -- within instance method definition
scope.

Unfortunately, the | | syntax for instance variables will
define
*class-instance* variables when used in class method
definition scope.

This was probably something you and Mike both missed.

> One of the things that I consider important is the
distinction or rather
> lack of distinction between class methods and instance
methods;  that
> classes objects to the same amount their own instances
are.  It was
> something I was unaware of and Smalltalk made it
instantly clear without
> lumping them together.  I think it should be kept that
way.

Agreed.

> Something that I didn't notice in the examples was pool
dictionaries.  I
> can't say I've seen any examples of how they're
actually used in
> practice but since they have to be declared in the
usual class
> definition, they're probably used for something.  Will
there be syntax
> to handle them?

Yes, it should be something like

    <import: PoolDictionary>

Paolo


_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

Re: Smalltalk scripting syntax
country flaguser name
United Kingdom
2007-03-13 14:42:45
[Pasting together your posts, to save electronic ink]

Paolo Bonzini wrote:
> Unfortunately, the | | syntax for instance variables
will define
> *class-instance* variables when used in class method
definition scope.
> 
> This was probably something you and Mike both missed.

I thought you might say that, but there's really no reason
why you
should insist on defining class instance variables in the
class method
scope. It's a nested scope, and Smalltalk has no inner
classes, so
there's no reason to treat it the same as the outer scope.

>> Actually, in spite of my comments, I *don't* have
much of a problem with
>> instance variables or instance methods at all. What
bothers me is the
>> class scoping and the class variables.
>>
>> What about declaring class variables using | |
inside the class scope?
>
> I answer parasti about that.  Suggestions are welcome
about class
> scoping improvements.  In particular, in what way does
it bother you?

The redundancy in the scope declaration and its message-send
form.

Well, I can see that I'm going to have to agree to disagree.
Bye for now.

Mike


_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

Re: Smalltalk scripting syntax
country flaguser name
Latvia
2007-03-13 15:11:12
Paolo Bonzini wrote:
>>     Object subclass: #MyClass.
>>     MyClass comment: 'A simple example class'.
> 
> Except that MyClass is not available yet...
> 
> One would need something like
> 
>         Object subclass: #MyClass!
>         MyClass comment: 'A simple example class'!
> 
> or
> 
>     Eval [
>         Object subclass: #MyClass.
>     ]
>     Eval [
>         MyClass comment: 'A simple example class'.
>     ]

Given the alternative I'd keep the exclamation point.  I
can't imagine
what would an interactive session look like.  I'm over my
head here,
though.  Come to think of it, Eval [] heavily reminds me of
an ordinary
function call.

>>   * Class and instance variables are defined the
same way, except that
>> class variables are defined within class method
definition scope and
>> instance variables -- within instance method
definition scope.
> 
> Unfortunately, the | | syntax for instance variables
will define
> *class-instance* variables when used in class method
definition scope.
> 
> This was probably something you and Mike both missed.

Oh, you're right.  I left class instance variables out of
the picture.
This is getting a bit confusing now...  I was trying to
figure out a way
without hijacking the temporary variable declaration.  I do
think that
it's better when all of the variables are explicitly
declared instead of
having their definitions being scattered all over the method
definition
scope.  (Or scopes!)  Well, class variables wouldn't,
anyway.  But I'd
rather choose that than using the temporary variable
declaration
literal.  I've gotten used to the idea that they're
"temporary" and
conceptually only exist during execution of something.  A
lifetime of an
object seems far too different to be called
"execution" of the object.

>> Something that I didn't notice in the examples was
pool dictionaries.  I
>> can't say I've seen any examples of how they're
actually used in
>> practice but since they have to be declared in the
usual class
>> definition, they're probably used for something. 
Will there be syntax
>> to handle them?
> 
> Yes, it should be something like
> 
>     <import: PoolDictionary>

Heh.  I guess that was simple one.  :-P

Jānis



_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )