Hello,

Can we use instance variables in CStruct?

The following snippet is working as expected:
> CStruct subclass: Sequence [
>     <declaration: #( (#maximum #uLong)
>                      (#length #uLong)
>                      (#buffer (#ptr #CObject))
>                      (#release #uChar) )>
> 
>     | arrayType |
> 
>     arrayType [
>         ^arrayType
>     ]
> 
>     arrayType: aType [
>         arrayType := aType
>     ]
> ]
> 
> Eval [
>     |s|
>     s := Sequence new.
>     s arrayType: CBoolean.
>     s arrayType inspect.
> ]

But embedding this CStruct with instance variable into another CStruct
does *not* work:
> CStruct subclass: EmbeddedSequence [
>     <declaration: #( (#days #uShort)
>                      (#intervals #{Sequence}) )>
> ]
> 
> Eval [
>     |eq|
>     eq := EmbeddedSequence new.
>     eq intervals arrayType: CBoolean.
>     eq intervals arrayType inspect.
> ]
because we get an UndefinedObject for arrayType. Somehow it seems the
instance variable arrayType cannot be reached.

I would expect either gst to reject the former snippet if instance
variable in CStruct is not allowed, or to correctly return what was
sent in the second snippet. Am I missing something?

Thanks,
Regards,

Thomas

_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to