[Xotcl] Suggestion needed

Victor Mayevski vitick at gmail.com
Tue Jan 20 11:28:20 CET 2015


That's beautiful! Thank you!





On Tue, Jan 20, 2015 at 1:11 AM, Stefan Sobernig <stefan.sobernig at wu.ac.at>
wrote:

> A more complete solution (preserving any pre-existing superclass lists) is
> as follows:
>
> package req nx
>
> namespace eval ::vitick {
>
>   Class create Object -superclasses nx::Object
>
>   Class create Class -superclasses nx::Class {
>     :method init {} {
>       ##
>       ## Rewire the default superclass
>       ##
>       if {[:info superclasses] eq "::nx::Object"} {
>         :configure -superclasses [namespace current]::Object
>       }
>
>     }
>   }
>
>   namespace export Object Class
> }
>
> namespace import -force ::vitick::*
>
> puts [[Class create MyClass] info superclasses]; # default is:
> ::vitick::Object
> puts [[Class create AnotherClass -superclasses MyClass] info
> superclasses]; # ::MyClass
> puts [[Class create AnotherClass -superclasses MyClass] info superclasses
> -closure]; # ::MyClass ::vitick::Object ::nx::Object
>
> //stefan
>
>  Hi Victor,
>>
>>  > Any suggestions?
>>
>> As always, there are several options. One way of nursing our custom
>> Object/Class is to use proper specializations of nx::Object/nx::Class:
>>
>> package req nx
>>
>> namespace eval ::vitick {
>>
>>    Class create Object -superclass nx::Object
>>
>>    Class create Class -superclass nx::Class {
>>      :method init {} {
>>        :configure -superclasses [namespace current]::Object
>>      }
>>    }
>>
>>    namespace export Object Class
>> }
>>
>> namespace import -force ::vitick::*
>>
>> This is less invasive and you have the benefit of monitoring any
>> changes/additions to nx::Object/nx::Class for free.
>>
>> Cheers,
>> Stefan
>> _______________________________________________
>> Xotcl mailing list
>> Xotcl at alice.wu-wien.ac.at
>> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>>
>
>
> --
> Institute for Information Systems and New Media
> Vienna University of Economics and Business
> Welthandelsplatz 1, Building D2, A-1020 Vienna
> Austria
>
> http://nm.wu.ac.at/en/sobernig
> stefan.sobernig at wu.ac.at
> ss at thinkersfoot.net
>
> t. +43-1-31336-4878
> f. +43-1-31336-746
>


More information about the Xotcl mailing list