Defining a class at runtime

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

Defining a class at runtime

Louis Moon
Hello. I've been playing around with Squeak the last couple of days, and I've found it pretty easy to use so far. However, I can't figure out how to do this (I'm trying mostly out of curiousity). I suspect it had something to do with the ClassBuilder class, but I can't figure out its usage. How's it done? Thanks for any help.

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Defining a class at runtime

Bert Freudenberg
On Jul 20, 2007, at 8:52 , Louis Moon wrote:

> Hello. I've been playing around with Squeak the last couple of  
> days, and I've found it pretty easy to use so far. However, I can't  
> figure out how to do this (I'm trying mostly out of curiousity). I  
> suspect it had something to do with the ClassBuilder class, but I  
> can't figure out its usage. How's it done? Thanks for any help.

In Squeak there is no "runtime". Just send the same message you use  
to create a class in a browser.

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Defining a class at runtime

Marcin Tustin


On 7/20/07, Bert Freudenberg <[hidden email]> wrote:
On Jul 20, 2007, at 8:52 , Louis Moon wrote:

> Hello. I've been playing around with Squeak the last couple of
> days, and I've found it pretty easy to use so far. However, I can't
> figure out how to do this (I'm trying mostly out of curiousity). I
> suspect it had something to do with the ClassBuilder class, but I
> can't figure out its usage. How's it done? Thanks for any help.

In Squeak there is no "runtime". Just send the same message you use
to create a class in a browser.

What is that message? We're all holding our breath.

(If you're not going to say that, I'll point out that it is possible to examine code in the browser to see how it does it.)

...and yes, of course, there is a runtime.

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Defining a class at runtime

Bert Freudenberg

On Jul 20, 2007, at 11:31 , Marcin Tustin wrote:

>
>
> On 7/20/07, Bert Freudenberg <[hidden email]> wrote: On Jul  
> 20, 2007, at 8:52 , Louis Moon wrote:
>
> > Hello. I've been playing around with Squeak the last couple of
> > days, and I've found it pretty easy to use so far. However, I can't
> > figure out how to do this (I'm trying mostly out of curiousity). I
> > suspect it had something to do with the ClassBuilder class, but I
> > can't figure out its usage. How's it done? Thanks for any help.
>
> In Squeak there is no "runtime". Just send the same message you use
> to create a class in a browser.
>
> What is that message? We're all holding our breath.
>
> (If you're not going to say that, I'll point out that it is  
> possible to examine code in the browser to see how it does it.)

Err, the message is right in your face:

Object subclass: #NameOfSubclass
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        category: 'Collections-Abstract'

> ...and yes, of course, there is a runtime.

Well, you could say there is only runtime. Which makes the term  
useless, as it implies some sort of opposite.

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Defining a class at runtime

Marcin Tustin


On 7/20/07, Bert Freudenberg <[hidden email]> wrote:

On Jul 20, 2007, at 11:31 , Marcin Tustin wrote:

>
>
> On 7/20/07, Bert Freudenberg <[hidden email]> wrote: On Jul
> 20, 2007, at 8:52 , Louis Moon wrote:

> ...and yes, of course, there is a runtime.

Well, you could say there is only runtime. Which makes the term
useless, as it implies some sort of opposite.

Then how would you refer to runtime? In any case, we can oppose it to code-definition time. Nothing exciting may happen then, but it's worth being able to talk about it.

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Defining a class at runtime

Bert Freudenberg
On Jul 20, 2007, at 11:57 , Marcin Tustin wrote:

> On 7/20/07, Bert Freudenberg <[hidden email]> wrote:
> On Jul 20, 2007, at 11:31 , Marcin Tustin wrote:
>
> >
> >
> > On 7/20/07, Bert Freudenberg <[hidden email]> wrote: On Jul
> > 20, 2007, at 8:52 , Louis Moon wrote:
>
> > ...and yes, of course, there is a runtime.
>
> Well, you could say there is only runtime. Which makes the term
> useless, as it implies some sort of opposite.
>
> Then how would you refer to runtime? In any case, we can oppose it  
> to code-definition time. Nothing exciting may happen then, but it's  
> worth being able to talk about it.

There is no technical distinction. All you do when "defining code" is  
creating an instance and adding it to a dictionary in some object.  
That's no different from other activities you do at "runtime".

The instance might be an instance of a metaclass and the dictionary  
might be held in a global variable called Smalltalk. Or the instance  
could happen to be a CompiledMethod instance, and the dictionary  
would be the method dictionary of a class object. So what?

Sending messages, creating instances, storing them in fields of other  
objects, wouldn't you call that "runtime" if you insist on that term?

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Defining a class at runtime

Marcin Tustin
Just because code definition happens as part of the runtime of the whole system does not mean that any piece of code does not have a code definition time during which one could arrange to, for example, do macro substitution.

On 7/20/07, Bert Freudenberg <[hidden email]> wrote:
On Jul 20, 2007, at 11:57 , Marcin Tustin wrote:

> On 7/20/07, Bert Freudenberg <[hidden email]> wrote:
> On Jul 20, 2007, at 11:31 , Marcin Tustin wrote:
>
> >
> >
> > On 7/20/07, Bert Freudenberg <[hidden email]> wrote: On Jul
> > 20, 2007, at 8:52 , Louis Moon wrote:
>
> > ...and yes, of course, there is a runtime.
>
> Well, you could say there is only runtime. Which makes the term
> useless, as it implies some sort of opposite.
>
> Then how would you refer to runtime? In any case, we can oppose it
> to code-definition time. Nothing exciting may happen then, but it's
> worth being able to talk about it.

There is no technical distinction. All you do when "defining code" is
creating an instance and adding it to a dictionary in some object.
That's no different from other activities you do at "runtime".

The instance might be an instance of a metaclass and the dictionary
might be held in a global variable called Smalltalk. Or the instance
could happen to be a CompiledMethod instance, and the dictionary
would be the method dictionary of a class object. So what?

Sending messages, creating instances, storing them in fields of other
objects, wouldn't you call that "runtime" if you insist on that term?

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Defining a class at runtime

Edgar J. De Cleene
In reply to this post by Bert Freudenberg



El 7/20/07 7:31 AM, "Bert Freudenberg" <[hidden email]> escribió:

>>> ...and yes, of course, there is a runtime.
>>
>> Well, you could say there is only runtime. Which makes the term
>> useless, as it implies some sort of opposite.
>>
>> Then how would you refer to runtime? In any case, we can oppose it
>> to code-definition time. Nothing exciting may happen then, but it's
>> worth being able to talk about it.
>
> There is no technical distinction. All you do when "defining code" is
> creating an instance and adding it to a dictionary in some object.
> That's no different from other activities you do at "runtime".
>
> The instance might be an instance of a metaclass and the dictionary
> might be held in a global variable called Smalltalk. Or the instance
> could happen to be a CompiledMethod instance, and the dictionary
> would be the method dictionary of a class object. So what?
>
> Sending messages, creating instances, storing them in fields of other
> objects, wouldn't you call that "runtime" if you insist on that term?
>
> - Bert -

Maybe Louis only use systems on which you need edit, compile, link, and run
:)

Edgar


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Defining a class at runtime

Bert Freudenberg
In reply to this post by Marcin Tustin
On Jul 20, 2007, at 12:48 , Marcin Tustin wrote:

> Just because code definition happens as part of the runtime of the  
> whole system does not mean that any piece of code does not have a  
> code definition time during which one could arrange to, for  
> example, do macro substitution.

This is the beginner's list. In my experience it helps beginners to  
understand Smalltalk better when they *truly* realize that everything  
is an object, and all that ever happens is that messages are sent to  
objects. This is hard to grok if you come from other environments.

Even the notion of "piece of code" distracts from this big picture.  
That string of characters just happens to be one user interface to  
the system. It also happens to be one external representation, albeit  
a very flawed one. Code isn't all that important for understanding  
Smalltalk. Objects are.

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners