discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

StepTalk introduces 'Script Objects'


From: Stefan Urbanek
Subject: StepTalk introduces 'Script Objects'
Date: Wed, 06 Aug 2003 22:29:22 +0200

Hi,

I am glad to announce that prototype of script objects exist in StepTalk CVS.

What are script objects? Objects composed of methods written as steptalk 
'scripts'. Well, instead of explanation, here is an example in Smalltalk of 
what is going on:

| object method source engine |
   Environment includeFramework:'StepTalk'.
" Create a script object and set it's environment "
   object := STScriptObject scriptObject.
   object setEnvironment:Environment.

" This is the source of new method "
   source := 'sayHi Transcript showLine: \'Hi.\'. ^self'.

" Get the proper engine "
   engine := STEngine engineForLanguageWithName:'Smalltalk'.

" Create method "
   method := engine methodFromSource:source
                         forReceiver:object
                       inEnvironment:Environment.

" Add the method to the object "
   object addMethod:method.

" Add another method with an argument "
   source := 'sayHiTo:someone Transcript showLine: (\'Hi \', someone). ^self'.
   method := engine methodFromSource:source
                         forReceiver:object
                       inEnvironment:Environment.
   object addMethod:method.

" Sent it! "
   object sayHi.
   object sayHiTo:'GNUstep'.

In other words, you can build behaviour of an object in various languages and 
then use it as any other object.
Implementors of language engines should look at new STMethod protocol and new 
two STEngine methods to see how to implement such feature. Currently there is 
no instance variable support, nor inheritance, however, it is planned.
You need actual CVS version. Moreover you have to completely remove your 
previous installation of StepTalk, because it has been changed to a framework.

Let me know what do you think of script objects.

Enjoy,

Stefan Urbanek
--
http://urbanek.host.sk

First they ignore you, then they laugh at you, then they fight you, then you 
win.
- Mahatma Gandhi






reply via email to

[Prev in Thread] Current Thread [Next in Thread]