On 16 December 2012 19:02, Ciprian Teodorov <[email protected]> wrote:
>
>
> On Sun, Dec 16, 2012 at 6:27 PM, Igor Stasenko <[email protected]> wrote:
>>
>> On 16 December 2012 16:05, Ciprian Teodorov <[email protected]>
>> wrote:
>> > Hi Igor,
>> >
>> > Besides some other small comits, in NativeBoost-Core-CiprianTeodorov.103
>> > I
>> > have changed the way anonymous subclasses of NBExternalTypeValue and
>> > NBExternalArray are created.
>> >
>> > The reason is that using the old way we would create multiple instances
>> > of
>> > the same metaclass which is not allowed in the image.
>> > BTW, I was getting this problem when trying to modify (add or remove)
>> > class
>> > instance variables of the NBExternalArray.
>>
>> So, your problem is that you abusing it :)
>
> Lool. Yes I abused it a little bit ... ;) but not this time.
>>
>> Anonymous subclasses is there for sole purpose to provide common
>> minimal protocol
>> for their instances.
>> If you need something else, you can just make normal subclasses.
>>
>
> In your image just do
>
> before := NBExternalArray class allInstances size.
> myFloatArray := NBExternalArray ofType: #NBFloat32 .
> after := NBExternalArray class allInstances size.
>
> {before. after} inspect.
>
> the number of metaclass instances should be one. If there are more you get
> errors when refactoring your class.
>
> Now just image that I have create a few of these external array types...
> before being able to touch the NBExternalArray ever again you have to
> somehow get rid of all wrong instances ... I did that yesterday and is not
> funny...
>
yes, not funny. but why touching NBExternalArray in a first place? :)
>
>>
>> > Doing NBExternalArray class allInstances, I was clearly getting more
>> > than
>> > one instance...
>> >
>> > Now the anonymous subclasses are build using
>> > ClassBuilder>>#newSubclassOf:type:instanceVariables:from: which seems to
>> > prevent this problem from happening.
>> >
>> > What do you think? Are there other ways to get around this problem?
>> >
>>
>> Sure , you can use class builder, but again, you need it because you
>> want to have
>> more than just minimal interface. So, again, why don't just create own
>> subclass?
>>
> I was playing a little bit with static arrays... passed by value on
> stack... you know I already told you that I want to use arrays in structures
> like struct {void *x[100]; }. I think that I can use the NBExternalStruct
> for that but ... seeing NBExternalArray tempted me
>
>
> And since we are here ;) one more question: Why the NBExternalArray does not
> have a type ? It seems to me that they are not symmetric with all other
> native types.
well, it adds another dimension to type system..
it needs to be implemented.. one day :)
Right now, for passing a pointer to array to some function, you can
use 'myArray address'
it works both for external/internal arrays.
--
Best regards,
Igor Stasenko.